summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/TargetAttributesSema.cpp
diff options
context:
space:
mode:
authorCharles Davis <cdavis@mines.edu>2010-02-10 23:06:52 +0000
committerCharles Davis <cdavis@mines.edu>2010-02-10 23:06:52 +0000
commitbbc0aa516623f73d606783a2e4594c50fed4a830 (patch)
tree3ab7b4c3231fc5c8752724b80a7f054d4c29baa2 /clang/lib/Sema/TargetAttributesSema.cpp
parentaf3fe9982116fe772960fa5fcfd05caaf9a7ba32 (diff)
downloadbcm5719-llvm-bbc0aa516623f73d606783a2e4594c50fed4a830.tar.gz
bcm5719-llvm-bbc0aa516623f73d606783a2e4594c50fed4a830.zip
Add support for the force_align_arg_pointer attribute. This is an x86-specific
attribute, so it uses Anton's new target-specific attribute support. It's supposed to ensure that the stack is 16-byte aligned, but since necessary support is lacking from LLVM, this is a no-op for now. llvm-svn: 95820
Diffstat (limited to 'clang/lib/Sema/TargetAttributesSema.cpp')
-rw-r--r--clang/lib/Sema/TargetAttributesSema.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/clang/lib/Sema/TargetAttributesSema.cpp b/clang/lib/Sema/TargetAttributesSema.cpp
index 7c19bf6e4fd..ab54949c995 100644
--- a/clang/lib/Sema/TargetAttributesSema.cpp
+++ b/clang/lib/Sema/TargetAttributesSema.cpp
@@ -70,6 +70,46 @@ namespace {
};
}
+static void HandleX86ForceAlignArgPointerAttr(Decl *D,
+ const AttributeList& Attr,
+ Sema &S) {
+ // Check the attribute arguments.
+ if (Attr.getNumArgs() != 0) {
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
+ return;
+ }
+
+ // If we try to apply it to a function pointer, don't warn, but don't
+ // do anything, either. It doesn't matter anyway, because there's nothing
+ // special about calling a force_align_arg_pointer function.
+ ValueDecl* VD = dyn_cast<ValueDecl>(D);
+ if(VD->getType()->isFunctionPointerType())
+ return;
+ // Attribute can only be applied to function types.
+ if(!isa<FunctionDecl>(D)) {
+ S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+ << Attr.getName() << /* function */0;
+ return;
+ }
+
+ D->addAttr(::new (S.Context) X86ForceAlignArgPointerAttr());
+}
+
+namespace {
+ class X86AttributesSema : public TargetAttributesSema {
+ public:
+ X86AttributesSema() { }
+ bool ProcessDeclAttribute(Scope *scope, Decl *D,
+ const AttributeList &Attr, Sema &S) const {
+ if (Attr.getName()->getName() == "force_align_arg_pointer") {
+ HandleX86ForceAlignArgPointerAttr(D, Attr, S);
+ return true;
+ }
+ return false;
+ }
+ };
+}
+
const TargetAttributesSema &Sema::getTargetAttributesSema() const {
if (TheTargetAttributesSema)
return *TheTargetAttributesSema;
@@ -81,6 +121,8 @@ const TargetAttributesSema &Sema::getTargetAttributesSema() const {
case llvm::Triple::msp430:
return *(TheTargetAttributesSema = new MSP430AttributesSema);
+ case llvm::Triple::x86:
+ return *(TheTargetAttributesSema = new X86AttributesSema);
}
}
OpenPOWER on IntegriCloud