diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2009-07-17 18:07:26 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2009-07-17 18:07:26 +0000 |
commit | c5ec8a78ea898087ad361e5b755f74a76150e5fd (patch) | |
tree | 0501e2931c39d02da499777594d2849184c508a2 /lib | |
parent | a9af7e626cec5b0b78cbb8f458be3c671b1f0750 (diff) |
Add support for naked functions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76198 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AsmParser/LLLexer.cpp | 1 | ||||
-rw-r--r-- | lib/AsmParser/LLParser.cpp | 1 | ||||
-rw-r--r-- | lib/AsmParser/LLToken.h | 1 | ||||
-rw-r--r-- | lib/CodeGen/PrologEpilogInserter.cpp | 7 | ||||
-rw-r--r-- | lib/VMCore/Attributes.cpp | 4 |
5 files changed, 11 insertions, 3 deletions
diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp index 97e8e6ad18..1dc463110b 100644 --- a/lib/AsmParser/LLLexer.cpp +++ b/lib/AsmParser/LLLexer.cpp @@ -541,6 +541,7 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(sspreq); KEYWORD(noredzone); KEYWORD(noimplicitfloat); + KEYWORD(naked); KEYWORD(type); KEYWORD(opaque); diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 080575df84..6a6478f37b 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -775,6 +775,7 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) { case lltok::kw_sspreq: Attrs |= Attribute::StackProtectReq; break; case lltok::kw_noredzone: Attrs |= Attribute::NoRedZone; break; case lltok::kw_noimplicitfloat: Attrs |= Attribute::NoImplicitFloat; break; + case lltok::kw_naked: Attrs |= Attribute::Naked; break; case lltok::kw_align: { unsigned Alignment; diff --git a/lib/AsmParser/LLToken.h b/lib/AsmParser/LLToken.h index b5194ad83f..8f813f39b6 100644 --- a/lib/AsmParser/LLToken.h +++ b/lib/AsmParser/LLToken.h @@ -84,6 +84,7 @@ namespace lltok { kw_sspreq, kw_noredzone, kw_noimplicitfloat, + kw_naked, kw_type, kw_opaque, diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp index 546a84ec87..5aa37c9044 100644 --- a/lib/CodeGen/PrologEpilogInserter.cpp +++ b/lib/CodeGen/PrologEpilogInserter.cpp @@ -51,6 +51,7 @@ FunctionPass *llvm::createPrologEpilogCodeInserter() { return new PEI(); } /// frame indexes with appropriate references. /// bool PEI::runOnMachineFunction(MachineFunction &Fn) { + const Function* F = Fn.getFunction(); const TargetRegisterInfo *TRI = Fn.getTarget().getRegisterInfo(); RS = TRI->requiresRegisterScavenging(Fn) ? new RegScavenger() : NULL; @@ -80,7 +81,8 @@ bool PEI::runOnMachineFunction(MachineFunction &Fn) { placeCSRSpillsAndRestores(Fn); // Add the code to save and restore the callee saved registers - insertCSRSpillsAndRestores(Fn); + if (!F->hasFnAttr(Attribute::Naked)) + insertCSRSpillsAndRestores(Fn); // Allow the target machine to make final modifications to the function // before the frame layout is finalized. @@ -94,7 +96,8 @@ bool PEI::runOnMachineFunction(MachineFunction &Fn) { // called functions. Because of this, calculateCalleeSavedRegisters // must be called before this function in order to set the HasCalls // and MaxCallFrameSize variables. - insertPrologEpilogCode(Fn); + if (!F->hasFnAttr(Attribute::Naked)) + insertPrologEpilogCode(Fn); // Replace all MO_FrameIndex operands with physical register references // and actual offsets. diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index 8dfbd1d502..5d763c34fe 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -40,7 +40,7 @@ std::string Attribute::getAsString(Attributes Attrs) { if (Attrs & Attribute::NoCapture) Result += "nocapture "; if (Attrs & Attribute::StructRet) - Result += "sret "; + Result += "sret "; if (Attrs & Attribute::ByVal) Result += "byval "; if (Attrs & Attribute::Nest) @@ -63,6 +63,8 @@ std::string Attribute::getAsString(Attributes Attrs) { Result += "noredzone "; if (Attrs & Attribute::NoImplicitFloat) Result += "noimplicitfloat "; + if (Attrs & Attribute::Naked) + Result += "naked "; if (Attrs & Attribute::Alignment) { Result += "align "; Result += utostr(Attribute::getAlignmentFromAttrs(Attrs)); |