summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Targets.cpp
diff options
context:
space:
mode:
authorToma Tabacu <toma.tabacu@imgtec.com>2015-01-12 14:41:30 +0000
committerToma Tabacu <toma.tabacu@imgtec.com>2015-01-12 14:41:30 +0000
commitcfab40f95b62581382901ca02428c2c6e2e3dbb8 (patch)
tree1b75aeb7aa0ee6cd15eac08a7c5cd575c9dcbc99 /clang/lib/Basic/Targets.cpp
parent335c08e56c9e793aa82706ce5869f683aec15369 (diff)
downloadbcm5719-llvm-cfab40f95b62581382901ca02428c2c6e2e3dbb8.tar.gz
bcm5719-llvm-cfab40f95b62581382901ca02428c2c6e2e3dbb8.zip
[mips] Explain why we need to always clobber for MIPS inline asm. NFC.
llvm-svn: 225632
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r--clang/lib/Basic/Targets.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 17014873220..dbb7fb7b3fb 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -5802,6 +5802,27 @@ public:
}
const char *getClobbers() const override {
+ // In GCC, $1 is not widely used in generated code (it's used only in a few
+ // specific situations), so there is no real need for users to add it to
+ // the clobbers list if they want to use it in their inline assembly code.
+ //
+ // In LLVM, $1 is treated as a normal GPR and is always allocatable during
+ // code generation, so using it in inline assembly without adding it to the
+ // clobbers list can cause conflicts between the inline assembly code and
+ // the surrounding generated code.
+ //
+ // Another problem is that LLVM is allowed to choose $1 for inline assembly
+ // operands, which will conflict with the ".set at" assembler option (which
+ // we use only for inline assembly, in order to maintain compatibility with
+ // GCC) and will also conflict with the user's usage of $1.
+ //
+ // The easiest way to avoid these conflicts and keep $1 as an allocatable
+ // register for generated code is to automatically clobber $1 for all inline
+ // assembly code.
+ //
+ // FIXME: We should automatically clobber $1 only for inline assembly code
+ // which actually uses it. This would allow LLVM to use $1 for inline
+ // assembly operands if the user's assembly code doesn't use it.
return "~{$1}";
}
OpenPOWER on IntegriCloud