mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
Add pure/const attributes. Documentation will follow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44109 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9de1934099
commit
0adb7b41e7
@ -29,16 +29,18 @@ namespace ParamAttr {
|
|||||||
/// results.
|
/// results.
|
||||||
/// @brief Function parameter attributes.
|
/// @brief Function parameter attributes.
|
||||||
enum Attributes {
|
enum Attributes {
|
||||||
None = 0, ///< No attributes have been set
|
None = 0, ///< No attributes have been set
|
||||||
ZExt = 1 << 0, ///< Zero extended before/after call
|
ZExt = 1 << 0, ///< Zero extended before/after call
|
||||||
SExt = 1 << 1, ///< Sign extended before/after call
|
SExt = 1 << 1, ///< Sign extended before/after call
|
||||||
NoReturn = 1 << 2, ///< Mark the function as not returning
|
NoReturn = 1 << 2, ///< Mark the function as not returning
|
||||||
InReg = 1 << 3, ///< Force argument to be passed in register
|
InReg = 1 << 3, ///< Force argument to be passed in register
|
||||||
StructRet = 1 << 4, ///< Hidden pointer to structure to return
|
StructRet = 1 << 4, ///< Hidden pointer to structure to return
|
||||||
NoUnwind = 1 << 5, ///< Function doesn't unwind stack
|
NoUnwind = 1 << 5, ///< Function doesn't unwind stack
|
||||||
NoAlias = 1 << 6, ///< Considered to not alias after call
|
NoAlias = 1 << 6, ///< Considered to not alias after call
|
||||||
ByVal = 1 << 7, ///< Pass structure by value
|
ByVal = 1 << 7, ///< Pass structure by value
|
||||||
Nest = 1 << 8 ///< Nested function static chain
|
Nest = 1 << 8, ///< Nested function static chain
|
||||||
|
Pure = 1 << 9, ///< Function is pure
|
||||||
|
Const = 1 << 10 ///< Function is const
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -275,6 +275,8 @@ noreturn { return NORETURN; }
|
|||||||
noalias { return NOALIAS; }
|
noalias { return NOALIAS; }
|
||||||
byval { return BYVAL; }
|
byval { return BYVAL; }
|
||||||
nest { return NEST; }
|
nest { return NEST; }
|
||||||
|
pure { return PURE; }
|
||||||
|
const { return CONST; }
|
||||||
sext{WSNL} { // For auto-upgrade only, drop in LLVM 3.0
|
sext{WSNL} { // For auto-upgrade only, drop in LLVM 3.0
|
||||||
return SIGNEXT; }
|
return SIGNEXT; }
|
||||||
zext{WSNL} { // For auto-upgrade only, drop in LLVM 3.0
|
zext{WSNL} { // For auto-upgrade only, drop in LLVM 3.0
|
||||||
|
@ -1113,6 +1113,7 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
|
|||||||
|
|
||||||
// Function Attributes
|
// Function Attributes
|
||||||
%token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST
|
%token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST
|
||||||
|
%token CONST PURE
|
||||||
|
|
||||||
// Visibility Styles
|
// Visibility Styles
|
||||||
%token DEFAULT HIDDEN PROTECTED
|
%token DEFAULT HIDDEN PROTECTED
|
||||||
@ -1256,6 +1257,8 @@ FuncAttr : NORETURN { $$ = ParamAttr::NoReturn; }
|
|||||||
| NOUNWIND { $$ = ParamAttr::NoUnwind; }
|
| NOUNWIND { $$ = ParamAttr::NoUnwind; }
|
||||||
| ZEROEXT { $$ = ParamAttr::ZExt; }
|
| ZEROEXT { $$ = ParamAttr::ZExt; }
|
||||||
| SIGNEXT { $$ = ParamAttr::SExt; }
|
| SIGNEXT { $$ = ParamAttr::SExt; }
|
||||||
|
| PURE { $$ = ParamAttr::Pure; }
|
||||||
|
| CONST { $$ = ParamAttr::Const; }
|
||||||
;
|
;
|
||||||
|
|
||||||
OptFuncAttrs : /* empty */ { $$ = ParamAttr::None; }
|
OptFuncAttrs : /* empty */ { $$ = ParamAttr::None; }
|
||||||
|
@ -108,6 +108,10 @@ ParamAttrsList::getParamAttrsText(uint16_t Attrs) {
|
|||||||
Result += "byval ";
|
Result += "byval ";
|
||||||
if (Attrs & ParamAttr::Nest)
|
if (Attrs & ParamAttr::Nest)
|
||||||
Result += "nest ";
|
Result += "nest ";
|
||||||
|
if (Attrs & ParamAttr::Pure)
|
||||||
|
Result += "pure ";
|
||||||
|
if (Attrs & ParamAttr::Const)
|
||||||
|
Result += "const ";
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +398,8 @@ void Verifier::visitFunction(Function &F) {
|
|||||||
ParamAttr::Nest | ParamAttr::StructRet;
|
ParamAttr::Nest | ParamAttr::StructRet;
|
||||||
|
|
||||||
const uint16_t ParameterIncompatible =
|
const uint16_t ParameterIncompatible =
|
||||||
ParamAttr::NoReturn | ParamAttr::NoUnwind;
|
ParamAttr::NoReturn | ParamAttr::NoUnwind |
|
||||||
|
ParamAttr::Const | ParamAttr::Pure;
|
||||||
|
|
||||||
const uint16_t MutuallyIncompatible =
|
const uint16_t MutuallyIncompatible =
|
||||||
ParamAttr::ByVal | ParamAttr::InReg |
|
ParamAttr::ByVal | ParamAttr::InReg |
|
||||||
@ -407,6 +408,9 @@ void Verifier::visitFunction(Function &F) {
|
|||||||
const uint16_t MutuallyIncompatible2 =
|
const uint16_t MutuallyIncompatible2 =
|
||||||
ParamAttr::ZExt | ParamAttr::SExt;
|
ParamAttr::ZExt | ParamAttr::SExt;
|
||||||
|
|
||||||
|
const uint16_t MutuallyIncompatible3 =
|
||||||
|
ParamAttr::Pure | ParamAttr::Const;
|
||||||
|
|
||||||
const uint16_t IntegerTypeOnly =
|
const uint16_t IntegerTypeOnly =
|
||||||
ParamAttr::SExt | ParamAttr::ZExt;
|
ParamAttr::SExt | ParamAttr::ZExt;
|
||||||
|
|
||||||
@ -423,9 +427,14 @@ void Verifier::visitFunction(Function &F) {
|
|||||||
uint16_t RetI = Attrs->getParamAttrs(0) & ReturnIncompatible;
|
uint16_t RetI = Attrs->getParamAttrs(0) & ReturnIncompatible;
|
||||||
Assert1(!RetI, "Attribute " + Attrs->getParamAttrsText(RetI) +
|
Assert1(!RetI, "Attribute " + Attrs->getParamAttrsText(RetI) +
|
||||||
"should not apply to functions!", &F);
|
"should not apply to functions!", &F);
|
||||||
uint16_t MutI = Attrs->getParamAttrs(0) & MutuallyIncompatible2;
|
|
||||||
Assert1(MutI != MutuallyIncompatible2, "Attributes" +
|
uint16_t MutI2 = Attrs->getParamAttrs(0) & MutuallyIncompatible2;
|
||||||
Attrs->getParamAttrsText(MutI) + "are incompatible!", &F);
|
Assert1(MutI2 != MutuallyIncompatible2, "Attributes" +
|
||||||
|
Attrs->getParamAttrsText(MutI2) + "are incompatible!", &F);
|
||||||
|
|
||||||
|
uint16_t MutI3 = Attrs->getParamAttrs(0) & MutuallyIncompatible3;
|
||||||
|
Assert1(MutI3 != MutuallyIncompatible3, "Attributes" +
|
||||||
|
Attrs->getParamAttrsText(MutI3) + "are incompatible!", &F);
|
||||||
|
|
||||||
for (FunctionType::param_iterator I = FT->param_begin(),
|
for (FunctionType::param_iterator I = FT->param_begin(),
|
||||||
E = FT->param_end(); I != E; ++I, ++Idx) {
|
E = FT->param_end(); I != E; ++I, ++Idx) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user