[cfe-dev] Help required for adding a new attribute
vivek pandya via cfe-dev
cfe-dev at lists.llvm.org
Mon Jul 11 03:47:20 PDT 2016
Hello Clang Developers,
I want to add a new attribute which is required to work with function
declaration as shown in example given below:
extern void foo(int param) __attribute__((regmask("R8,R11")));
int foo2(int param) {
foo(param);
return param;
}
For this I have done following changes:
Attr.td
def RegMask : Attr {
let Spellings = [GNU<"regmask">];
let Args = [StringArgument<"ClobbersList">];
let Subjects = SubjectList<[Function]>;
let Documentation = [Undocumented];
}
lib/Sema/SemaDeclAttr.cpp
static void handleRegMaskAttr(Sema &S, Decl *D, const AttributeList &Attr) {
// Make sure that there is a string literal as the annotation's single
// argument.
StringRef Str;
if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))
return;
D->addAttr(::new (S.Context)
AnnotateAttr(Attr.getRange(), S.Context, Str,
Attr.getAttributeSpellingListIndex()));
llvm::dbgs() << "Reg Mask attribute : " << Str << "\n";
}
above method is very similar to handleAnnotateAttr
and use this method inside ProcessDeclAttribute method as follows :
// Attribute to help interprocedural register allocation
case AttributeList::AT_RegMask:
handleRegMaskAttr(S, D, Attr);
break;
}
but this does not work for me, it works on function definitions but not
with function declaration.
Am I missing here any thing?
Note: I want to parse this string at MI level if possible or at IR level to
create a RegMask out of that.
Sincerely,
Vivek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160711/d4755e2f/attachment.html>
More information about the cfe-dev
mailing list