-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang] Add per-global code model attribute
This patch adds a per-global code model attribute, which can override the target's code model to access global variables. Currently, the code model attribute is only supported on LoongArch. This patch also maps GCC's code model names to LLVM's, which allows for better compatibility between the two compilers. Suggested-by: Arthur Eubanks <[email protected]> Signed-off-by: WANG Rui <[email protected]> Link: https://discourse.llvm.org/t/how-to-best-implement-code-model-overriding-for-certain-values/71816 Link: https://discourse.llvm.org/t/rfc-add-per-global-code-model-attribute/74944
- Loading branch information
Showing
8 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// RUN: %clang_cc1 -emit-llvm -triple loongarch64 %s -o - | FileCheck %s | ||
|
||
// CHECK: @normal ={{.*}} global i32 0, code_model "small" | ||
int normal __attribute__((model("normal"))); | ||
|
||
// CHECK: @medium ={{.*}} global i32 0, code_model "medium" | ||
int medium __attribute__((model("medium"))); | ||
|
||
// CHECK: @extreme ={{.*}} global i32 0, code_model "large" | ||
int extreme __attribute__((model("extreme"))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: %clang_cc1 -triple loongarch64 -verify -fsyntax-only %s | ||
|
||
#if !__has_attribute(model) | ||
#error "Should support model attribute" | ||
#endif | ||
|
||
int a __attribute((model("tiny"))); // expected-error {{code_model 'tiny' is not yet supported on this target}} | ||
int b __attribute((model("small"))); // expected-error {{code_model 'small' is not yet supported on this target}} | ||
int c __attribute((model("normal"))); // no-warning | ||
int d __attribute((model("kernel"))); // expected-error {{code_model 'kernel' is not yet supported on this target}} | ||
int e __attribute((model("medium"))); // no-warning | ||
int f __attribute((model("large"))); // expected-error {{code_model 'large' is not yet supported on this target}} | ||
int g __attribute((model("extreme"))); // no-warning |