This patch will make clang put the mips16/nomips16 attribute in function
bitcode for functions
which contain that attribute
Index: test/CodeGen/mips16-attr.c
===================================================================
--- test/CodeGen/mips16-attr.c (revision 0)
+++ test/CodeGen/mips16-attr.c (revision 0)
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple mipsel-linux-gnu -emit-llvm -o - %s | FileCheck %s
+void __attribute__((mips16)) foo (void) {
+
+}
+
+// CHECK: define void @foo() [[MIPS16:#[0-9]+]]
+
+void __attribute__((nomips16)) nofoo (void) {
+
+}
+
+// CHECK: define void @nofoo() [[NOMIPS16:#[0-9]+]]
+
+// CHECK: attributes [[MIPS16]] = { nounwind "fp-contract-model"="standard"
"mips16" {{.*}} }
+
+// CHECK: attributes [[NOMIPS16]] = { nounwind "fp-contract-model"="standard"
"nomips16" {{.*}} }
+
Index: lib/CodeGen/TargetInfo.cpp
===================================================================
--- lib/CodeGen/TargetInfo.cpp (revision 176874)
+++ lib/CodeGen/TargetInfo.cpp (working copy)
@@ -4321,11 +4321,18 @@
void SetTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM) const {
- //
- // can fill this in when new attribute work in llvm is done.
- // attributes mips16 and nomips16 need to be handled here.
- //
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ if (!FD) return;
+ llvm::Function *Fn = cast<llvm::Function>(GV);
+ if (FD->hasAttr<Mips16Attr>()) {
+ Fn->addFnAttr("mips16");
+ }
+ else if (FD->hasAttr<NoMips16Attr>()) {
+ Fn->addFnAttr("nomips16");
+ }
+ }
}
+
bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
llvm::Value *Address) const;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits