mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Add support for naked functions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76198 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a9af7e626c
commit
c5ec8a78ea
@ -1109,6 +1109,9 @@ red zone, even if the target-specific ABI normally permits it.
|
|||||||
<dt><tt>noimplicitfloat</tt></dt>
|
<dt><tt>noimplicitfloat</tt></dt>
|
||||||
<dd>This attributes disables implicit floating point instructions.</dd>
|
<dd>This attributes disables implicit floating point instructions.</dd>
|
||||||
|
|
||||||
|
<dt><tt>naked</tt></dt>
|
||||||
|
<dd>This attribute disables prologue / epilogue emission for the function</dd>
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -98,7 +98,8 @@ typedef enum {
|
|||||||
LLVMByValAttribute = 1<<7,
|
LLVMByValAttribute = 1<<7,
|
||||||
LLVMNestAttribute = 1<<8,
|
LLVMNestAttribute = 1<<8,
|
||||||
LLVMReadNoneAttribute = 1<<9,
|
LLVMReadNoneAttribute = 1<<9,
|
||||||
LLVMReadOnlyAttribute = 1<<10
|
LLVMReadOnlyAttribute = 1<<10,
|
||||||
|
LLVMNakedAttribute = 1<<24
|
||||||
} LLVMAttribute;
|
} LLVMAttribute;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -57,6 +57,7 @@ const Attributes NoCapture = 1<<21; ///< Function creates no aliases of pointer
|
|||||||
const Attributes NoRedZone = 1<<22; /// disable redzone
|
const Attributes NoRedZone = 1<<22; /// disable redzone
|
||||||
const Attributes NoImplicitFloat = 1<<23; /// disable implicit floating point
|
const Attributes NoImplicitFloat = 1<<23; /// disable implicit floating point
|
||||||
/// instructions.
|
/// instructions.
|
||||||
|
const Attributes Naked = 1<<24; ///< Naked function
|
||||||
|
|
||||||
/// @brief Attributes that only apply to function parameters.
|
/// @brief Attributes that only apply to function parameters.
|
||||||
const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture;
|
const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture;
|
||||||
@ -65,7 +66,7 @@ const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture;
|
|||||||
/// be used on return values or function parameters.
|
/// be used on return values or function parameters.
|
||||||
const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly |
|
const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly |
|
||||||
NoInline | AlwaysInline | OptimizeForSize | StackProtect | StackProtectReq |
|
NoInline | AlwaysInline | OptimizeForSize | StackProtect | StackProtectReq |
|
||||||
NoRedZone | NoImplicitFloat;
|
NoRedZone | NoImplicitFloat | Naked;
|
||||||
|
|
||||||
/// @brief Parameter attributes that do not apply to vararg call arguments.
|
/// @brief Parameter attributes that do not apply to vararg call arguments.
|
||||||
const Attributes VarArgsIncompatible = StructRet;
|
const Attributes VarArgsIncompatible = StructRet;
|
||||||
|
@ -541,6 +541,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
|||||||
KEYWORD(sspreq);
|
KEYWORD(sspreq);
|
||||||
KEYWORD(noredzone);
|
KEYWORD(noredzone);
|
||||||
KEYWORD(noimplicitfloat);
|
KEYWORD(noimplicitfloat);
|
||||||
|
KEYWORD(naked);
|
||||||
|
|
||||||
KEYWORD(type);
|
KEYWORD(type);
|
||||||
KEYWORD(opaque);
|
KEYWORD(opaque);
|
||||||
|
@ -775,6 +775,7 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
|
|||||||
case lltok::kw_sspreq: Attrs |= Attribute::StackProtectReq; break;
|
case lltok::kw_sspreq: Attrs |= Attribute::StackProtectReq; break;
|
||||||
case lltok::kw_noredzone: Attrs |= Attribute::NoRedZone; break;
|
case lltok::kw_noredzone: Attrs |= Attribute::NoRedZone; break;
|
||||||
case lltok::kw_noimplicitfloat: Attrs |= Attribute::NoImplicitFloat; break;
|
case lltok::kw_noimplicitfloat: Attrs |= Attribute::NoImplicitFloat; break;
|
||||||
|
case lltok::kw_naked: Attrs |= Attribute::Naked; break;
|
||||||
|
|
||||||
case lltok::kw_align: {
|
case lltok::kw_align: {
|
||||||
unsigned Alignment;
|
unsigned Alignment;
|
||||||
|
@ -84,6 +84,7 @@ namespace lltok {
|
|||||||
kw_sspreq,
|
kw_sspreq,
|
||||||
kw_noredzone,
|
kw_noredzone,
|
||||||
kw_noimplicitfloat,
|
kw_noimplicitfloat,
|
||||||
|
kw_naked,
|
||||||
|
|
||||||
kw_type,
|
kw_type,
|
||||||
kw_opaque,
|
kw_opaque,
|
||||||
|
@ -51,6 +51,7 @@ FunctionPass *llvm::createPrologEpilogCodeInserter() { return new PEI(); }
|
|||||||
/// frame indexes with appropriate references.
|
/// frame indexes with appropriate references.
|
||||||
///
|
///
|
||||||
bool PEI::runOnMachineFunction(MachineFunction &Fn) {
|
bool PEI::runOnMachineFunction(MachineFunction &Fn) {
|
||||||
|
const Function* F = Fn.getFunction();
|
||||||
const TargetRegisterInfo *TRI = Fn.getTarget().getRegisterInfo();
|
const TargetRegisterInfo *TRI = Fn.getTarget().getRegisterInfo();
|
||||||
RS = TRI->requiresRegisterScavenging(Fn) ? new RegScavenger() : NULL;
|
RS = TRI->requiresRegisterScavenging(Fn) ? new RegScavenger() : NULL;
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ bool PEI::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
placeCSRSpillsAndRestores(Fn);
|
placeCSRSpillsAndRestores(Fn);
|
||||||
|
|
||||||
// Add the code to save and restore the callee saved registers
|
// Add the code to save and restore the callee saved registers
|
||||||
|
if (!F->hasFnAttr(Attribute::Naked))
|
||||||
insertCSRSpillsAndRestores(Fn);
|
insertCSRSpillsAndRestores(Fn);
|
||||||
|
|
||||||
// Allow the target machine to make final modifications to the function
|
// Allow the target machine to make final modifications to the function
|
||||||
@ -94,6 +96,7 @@ bool PEI::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
// called functions. Because of this, calculateCalleeSavedRegisters
|
// called functions. Because of this, calculateCalleeSavedRegisters
|
||||||
// must be called before this function in order to set the HasCalls
|
// must be called before this function in order to set the HasCalls
|
||||||
// and MaxCallFrameSize variables.
|
// and MaxCallFrameSize variables.
|
||||||
|
if (!F->hasFnAttr(Attribute::Naked))
|
||||||
insertPrologEpilogCode(Fn);
|
insertPrologEpilogCode(Fn);
|
||||||
|
|
||||||
// Replace all MO_FrameIndex operands with physical register references
|
// Replace all MO_FrameIndex operands with physical register references
|
||||||
|
@ -63,6 +63,8 @@ std::string Attribute::getAsString(Attributes Attrs) {
|
|||||||
Result += "noredzone ";
|
Result += "noredzone ";
|
||||||
if (Attrs & Attribute::NoImplicitFloat)
|
if (Attrs & Attribute::NoImplicitFloat)
|
||||||
Result += "noimplicitfloat ";
|
Result += "noimplicitfloat ";
|
||||||
|
if (Attrs & Attribute::Naked)
|
||||||
|
Result += "naked ";
|
||||||
if (Attrs & Attribute::Alignment) {
|
if (Attrs & Attribute::Alignment) {
|
||||||
Result += "align ";
|
Result += "align ";
|
||||||
Result += utostr(Attribute::getAlignmentFromAttrs(Attrs));
|
Result += utostr(Attribute::getAlignmentFromAttrs(Attrs));
|
||||||
|
Loading…
Reference in New Issue
Block a user