2008-05-23 06:45:03 +08:00
|
|
|
(*
|
|
|
|
|
|
|
|
polygen grammar for LLVM assembly language.
|
|
|
|
|
|
|
|
This file defines an LLVM assembly language grammar for polygen,
|
|
|
|
which is a tool for generating random text based on a grammar.
|
|
|
|
It is strictly syntax-based, and makes no attempt to generate
|
|
|
|
IR that is semantically valid. Most of the IR produced doesn't
|
|
|
|
pass the Verifier.
|
|
|
|
|
2010-08-05 01:01:59 +08:00
|
|
|
TODO: Metadata, in all its forms
|
|
|
|
|
2008-05-23 06:45:03 +08:00
|
|
|
*)
|
|
|
|
|
|
|
|
I ::= "title: LLVM assembly language\n"
|
|
|
|
^ "status: experimental\n"
|
|
|
|
^ "audience: LLVM developers\n"
|
|
|
|
;
|
|
|
|
|
|
|
|
S ::= Module ;
|
|
|
|
|
|
|
|
(*
|
|
|
|
Define rules for non-keyword tokens. This is currently just a bunch
|
|
|
|
of hacks. They don't cover many valid forms of tokens, and they also
|
|
|
|
generate some invalid forms of tokens. The LLVM parser has custom
|
|
|
|
C++ code to lex these; custom C++ code for emitting them would be
|
|
|
|
convenient, but polygen doesn't support that.
|
|
|
|
*)
|
|
|
|
NonZeroDecimalDigit ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ;
|
|
|
|
DecimalDigit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ;
|
|
|
|
DecimalDigitSeq ::= DecimalDigit [^ DecimalDigitSeq ];
|
|
|
|
HexDigit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
|
|
| a | b | c | d | e | f ;
|
|
|
|
HexDigitSeq ::= HexDigit [^ HexDigitSeq ];
|
|
|
|
StringChar ::= a | b | c | d | e | f | g | h | i | j | k | l | m
|
|
|
|
| n | o | p | q | r | s | t | u | v | w | x | y | z ;
|
|
|
|
StringConstantSeq ::= StringChar [^ StringConstantSeq ];
|
|
|
|
StringConstant ::= StringChar [^ StringConstantSeq ];
|
|
|
|
EUINT64VAL ::= NonZeroDecimalDigit [^ DecimalDigitSeq ];
|
|
|
|
ESINT64VAL ::= [ "-" ] ^ EUINT64VAL ;
|
|
|
|
EUAPINTVAL ::= EUINT64VAL ;
|
|
|
|
ESAPINTVAL ::= ESINT64VAL ;
|
|
|
|
LOCALVALID ::= "%" ^ DecimalDigitSeq ;
|
|
|
|
GLOBALVALID ::= "@" ^ DecimalDigitSeq ;
|
|
|
|
INTTYPE ::= "i" ^ EUINT64VAL ;
|
|
|
|
GLOBALVAR ::= "@" ^ StringConstant ;
|
|
|
|
LOCALVAR ::= "%" ^ StringConstant ;
|
|
|
|
STRINGCONSTANT ::= "\"" ^ StringConstant ^ "\"" ;
|
|
|
|
ATSTRINGCONSTANT ::= "@" ^ STRINGCONSTANT ;
|
|
|
|
PCTSTRINGCONSTANT ::= "%" ^ STRINGCONSTANT ;
|
|
|
|
LABELSTR ::= StringConstant ;
|
|
|
|
FPVAL ::= ESAPINTVAL ^ "." ^ EUAPINTVAL | "0x" ^ HexDigitSeq ;
|
|
|
|
|
|
|
|
(*
|
|
|
|
The rest of this file is derived directly from llvmAsmParser.y.
|
|
|
|
*)
|
|
|
|
|
2009-07-23 06:45:30 +08:00
|
|
|
ArithmeticOps ::= + OptNW add | fadd | OptNW sub | fsub | OptNW mul | fmul |
|
|
|
|
udiv | OptExact sdiv | fdiv | urem | srem | frem ;
|
2008-05-23 06:45:03 +08:00
|
|
|
LogicalOps ::= shl | lshr | ashr | and | or | xor;
|
|
|
|
CastOps ::= trunc | zext | sext | fptrunc | fpext | bitcast |
|
|
|
|
uitofp | sitofp | fptoui | fptosi | inttoptr | ptrtoint ;
|
|
|
|
|
|
|
|
IPredicates ::= eq | ne | slt | sgt | sle | sge | ult | ugt | ule | uge ;
|
|
|
|
|
|
|
|
FPredicates ::= oeq | one | olt | ogt | ole | oge | ord | uno | ueq | une
|
|
|
|
| ult | ugt | ule | uge | true | false ;
|
|
|
|
|
|
|
|
IntType ::= INTTYPE;
|
2021-03-03 10:00:10 +08:00
|
|
|
FPType ::= half | bfloat | float | double | "ppc_fp128" | fp128 | "x86_fp80";
|
2008-05-23 06:45:03 +08:00
|
|
|
|
|
|
|
LocalName ::= LOCALVAR | STRINGCONSTANT | PCTSTRINGCONSTANT ;
|
|
|
|
OptLocalName ::= LocalName | _ ;
|
|
|
|
|
2009-01-06 01:29:42 +08:00
|
|
|
OptAddrSpace ::= - addrspace ^ "(" ^ EUINT64VAL ^ ")" | _ ;
|
2008-05-23 06:45:03 +08:00
|
|
|
|
|
|
|
OptLocalAssign ::= LocalName "=" | _ ;
|
|
|
|
|
|
|
|
GlobalName ::= GLOBALVAR | ATSTRINGCONSTANT ;
|
|
|
|
|
|
|
|
OptGlobalAssign ::= GlobalAssign | _ ;
|
|
|
|
|
|
|
|
GlobalAssign ::= GlobalName "=" ;
|
|
|
|
|
|
|
|
GVInternalLinkage
|
|
|
|
::= + internal
|
|
|
|
| weak
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 23:45:40 +08:00
|
|
|
| "weak_odr"
|
2008-05-23 06:45:03 +08:00
|
|
|
| linkonce
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 23:45:40 +08:00
|
|
|
| "linkonce_odr"
|
2008-05-23 06:45:03 +08:00
|
|
|
| appending
|
|
|
|
| dllexport
|
|
|
|
| common
|
2009-07-17 09:07:45 +08:00
|
|
|
| private
|
2008-05-23 06:45:03 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
GVExternalLinkage
|
|
|
|
::= dllimport
|
|
|
|
| "extern_weak"
|
|
|
|
| + external
|
|
|
|
;
|
|
|
|
|
|
|
|
GVVisibilityStyle
|
|
|
|
::= + _
|
|
|
|
| default
|
|
|
|
| hidden
|
|
|
|
| protected
|
|
|
|
;
|
|
|
|
|
|
|
|
FunctionDeclareLinkage
|
|
|
|
::= + _
|
|
|
|
| dllimport
|
|
|
|
| "extern_weak"
|
|
|
|
;
|
|
|
|
|
|
|
|
FunctionDefineLinkage
|
|
|
|
::= + _
|
|
|
|
| internal
|
|
|
|
| linkonce
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 23:45:40 +08:00
|
|
|
| "linkonce_odr"
|
2008-05-23 06:45:03 +08:00
|
|
|
| weak
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 23:45:40 +08:00
|
|
|
| "weak_odr"
|
2008-05-23 06:45:03 +08:00
|
|
|
| dllexport
|
|
|
|
;
|
|
|
|
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
llvm-svn: 66339
2009-03-07 23:45:40 +08:00
|
|
|
AliasLinkage ::= + _ | weak | "weak_odr" | internal ;
|
2008-05-23 06:45:03 +08:00
|
|
|
|
|
|
|
OptCallingConv ::= + _ |
|
|
|
|
ccc |
|
|
|
|
fastcc |
|
|
|
|
coldcc |
|
|
|
|
"x86_stdcallcc" |
|
|
|
|
"x86_fastcallcc" |
|
|
|
|
cc EUINT64VAL ;
|
|
|
|
|
|
|
|
ParamAttr ::= zeroext
|
|
|
|
| signext
|
|
|
|
| inreg
|
|
|
|
| sret
|
|
|
|
| noalias
|
2009-01-05 11:21:23 +08:00
|
|
|
| nocapture
|
2008-05-23 06:45:03 +08:00
|
|
|
| byval
|
|
|
|
| nest
|
|
|
|
| align EUINT64VAL
|
|
|
|
;
|
|
|
|
|
|
|
|
OptParamAttrs ::= + _ | OptParamAttrs ParamAttr ;
|
|
|
|
|
2009-01-05 11:21:23 +08:00
|
|
|
RetAttr ::= inreg
|
|
|
|
| zeroext
|
|
|
|
| signext
|
|
|
|
| noalias
|
|
|
|
;
|
|
|
|
|
|
|
|
OptRetAttrs ::= _
|
|
|
|
| OptRetAttrs RetAttr
|
|
|
|
;
|
|
|
|
|
2008-05-23 06:45:03 +08:00
|
|
|
FuncAttr ::= noreturn
|
|
|
|
| nounwind
|
2009-01-05 11:21:23 +08:00
|
|
|
| inreg
|
2008-05-23 06:45:03 +08:00
|
|
|
| zeroext
|
|
|
|
| signext
|
|
|
|
| readnone
|
|
|
|
| readonly
|
2010-02-06 09:16:28 +08:00
|
|
|
| inlinehint
|
2010-03-02 01:53:39 +08:00
|
|
|
| alignstack
|
2009-01-05 11:21:23 +08:00
|
|
|
| noinline
|
|
|
|
| alwaysinline
|
|
|
|
| optsize
|
|
|
|
| ssp
|
|
|
|
| sspreq
|
2011-10-04 11:08:43 +08:00
|
|
|
| returns_twice
|
2011-06-16 04:36:13 +08:00
|
|
|
| nonlazybind
|
2013-02-26 14:58:09 +08:00
|
|
|
| sanitize_address
|
|
|
|
| sanitize_thread
|
|
|
|
| sanitize_memory
|
[LangRef] Define mustprogress attribute
LLVM IR currently assumes some form of forward progress. This form is
not explicitly defined anywhere, and is the cause of miscompilations
in most languages that are not C++11 or later. This implicit forward progress
guarantee can not be opted out of on a function level nor on a loop
level. Languages such as C (C11 and later), C++ (pre-C++11), and Rust
have different forward progress requirements and this needs to be
evident in the IR.
Specifically, C11 and onwards (6.8.5, Paragraph 6) states that "An
iteration statement whose controlling expression is not a constant
expression, that performs no input/output operations, does not access
volatile objects, and performs no synchronization or atomic operations
in its body, controlling expression, or (in the case of for statement)
its expression-3, may be assumed by the implementation to terminate."
C++11 and onwards does not have this assumption, and instead assumes
that every thread must make progress as defined in [intro.progress] when
it comes to scheduling.
This was initially brought up in [0] as a bug, a solution was presented
in [1] which is the current workaround, and the predecessor to this
change was [2].
After defining a notion of forward progress for IR, there are two
options to address this:
1) Set the default to assuming Forward Progress and provide an opt-out for functions and an opt-in for loops.
2) Set the default to not assuming Forward Progress and provide an opt-in for functions, and an opt-in for loops.
Option 2) has been selected because only C++11 and onwards have a
forward progress requirement and it makes sense for them to opt-into it
via the defined `mustprogress` function attribute. The `mustprogress`
function attribute indicates that the function is required to make
forward progress as defined. This is sharply in contrast to the status
quo where this is implicitly assumed. In addition, `willreturn` implies `mustprogress`.
The background for why this definition was chosen is in [3] and for why
the option was chosen is in [4] and the corresponding thread(s). The implementation is in D85393, the
clang patch is in D86841, the LoopDeletion patch is in D86844, the
Inliner patches are in D87180 and D87262, and there will be more
incoming.
[0] https://bugs.llvm.org/show_bug.cgi?id=965#c25
[1] https://lists.llvm.org/pipermail/llvm-dev/2017-October/118558.html
[2] https://reviews.llvm.org/D65718
[3] https://lists.llvm.org/pipermail/llvm-dev/2020-September/144919.html
[4] https://lists.llvm.org/pipermail/llvm-dev/2020-September/145023.html
Reviewed By: jdoerfert, efriedma, nikic
Differential Revision: https://reviews.llvm.org/D86233
2020-10-20 01:29:10 +08:00
|
|
|
| mustprogress
|
2021-05-25 18:29:00 +08:00
|
|
|
| nosanitize_coverage
|
2008-05-23 06:45:03 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
OptFuncAttrs ::= + _ | OptFuncAttrs FuncAttr ;
|
|
|
|
|
|
|
|
OptGC ::= + _ | gc STRINGCONSTANT ;
|
|
|
|
|
|
|
|
OptAlign ::= + _ | align EUINT64VAL ;
|
|
|
|
OptCAlign ::= + _ | ^ "," align EUINT64VAL ;
|
|
|
|
|
|
|
|
SectionString ::= section STRINGCONSTANT ;
|
|
|
|
|
|
|
|
OptSection ::= + _ | SectionString ;
|
|
|
|
|
|
|
|
GlobalVarAttributes ::= + _ | ^ "," GlobalVarAttribute GlobalVarAttributes ;
|
|
|
|
GlobalVarAttribute ::= SectionString | align EUINT64VAL ;
|
|
|
|
|
2021-03-03 10:00:10 +08:00
|
|
|
PrimType ::= INTTYPE | half | bfloat | float | double | "ppc_fp128" | fp128
|
|
|
|
| "x86_fp80" | "x86_mmx" | "x86_amx" | - label ;
|
2008-05-23 06:45:03 +08:00
|
|
|
|
|
|
|
Types
|
|
|
|
::= opaque
|
|
|
|
| PrimType
|
|
|
|
| Types OptAddrSpace ^ "*"
|
|
|
|
| SymbolicValueRef
|
|
|
|
| "\\" ^ EUINT64VAL
|
|
|
|
| Types "(" ^ ArgTypeListI ^ ")" OptFuncAttrs
|
|
|
|
| void "(" ^ ArgTypeListI ^ ")" OptFuncAttrs
|
|
|
|
| "[" ^ EUINT64VAL "x" Types ^ "]"
|
|
|
|
| "<" ^ EUINT64VAL "x" Types ^ ">"
|
|
|
|
| "{" TypeListI "}"
|
2008-09-16 00:10:51 +08:00
|
|
|
| "{" ^ "}"
|
2008-05-23 06:45:03 +08:00
|
|
|
| "<" ^ "{" TypeListI "}" ^ ">"
|
2008-09-16 00:10:51 +08:00
|
|
|
| "<" ^ "{" ^ "}" ^ ">"
|
2008-05-23 06:45:03 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
ArgType ::= Types OptParamAttrs ;
|
|
|
|
|
|
|
|
ResultTypes ::= Types | void ;
|
|
|
|
|
|
|
|
ArgTypeList ::= ArgType | ArgTypeList ^ "," ArgType ;
|
|
|
|
|
|
|
|
ArgTypeListI ::= ArgTypeList | ArgTypeList ^ "," "..." | "..." | _ ;
|
|
|
|
|
|
|
|
TypeListI ::= Types | TypeListI ^ "," Types ;
|
|
|
|
|
|
|
|
ConstVal::= Types "[" ^ ConstVector ^ "]"
|
2008-09-16 00:10:51 +08:00
|
|
|
| Types "[" ^ "]"
|
2008-05-23 06:45:03 +08:00
|
|
|
| Types "c" ^ STRINGCONSTANT
|
|
|
|
| Types "<" ^ ConstVector ^ ">"
|
|
|
|
| Types "{" ConstVector "}"
|
2008-09-16 00:10:51 +08:00
|
|
|
| Types "{" ^ "}"
|
2008-05-23 06:45:03 +08:00
|
|
|
| Types "<" ^ "{" ConstVector "}" ^ ">"
|
2008-09-16 00:10:51 +08:00
|
|
|
| Types "<" ^ "{" ^ "}" ^ ">"
|
2008-05-23 06:45:03 +08:00
|
|
|
| Types null
|
|
|
|
| Types undef
|
|
|
|
| Types SymbolicValueRef
|
|
|
|
| Types ConstExpr
|
|
|
|
| Types zeroinitializer
|
2009-01-05 11:21:23 +08:00
|
|
|
| Types ESINT64VAL
|
|
|
|
| Types ESAPINTVAL
|
|
|
|
| Types EUINT64VAL
|
|
|
|
| Types EUAPINTVAL
|
|
|
|
| Types true
|
|
|
|
| Types false
|
|
|
|
| Types FPVAL ;
|
2008-05-23 06:45:03 +08:00
|
|
|
|
|
|
|
ConstExpr::= CastOps "(" ^ ConstVal to Types ^ ")"
|
2009-07-28 05:55:32 +08:00
|
|
|
| getelementptr OptInBounds "(" ^ ConstVal IndexList ^ ")"
|
2008-05-23 06:45:03 +08:00
|
|
|
| select "(" ^ ConstVal ^ "," ConstVal ^ "," ConstVal ^ ")"
|
|
|
|
| ArithmeticOps "(" ^ ConstVal ^ "," ConstVal ^ ")"
|
|
|
|
| LogicalOps "(" ^ ConstVal ^ "," ConstVal ^ ")"
|
|
|
|
| icmp IPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")"
|
|
|
|
| fcmp FPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")"
|
|
|
|
| extractelement "(" ^ ConstVal ^ "," ConstVal ^ ")"
|
|
|
|
| insertelement "(" ^ ConstVal ^ "," ConstVal ^ "," ConstVal ^ ")"
|
2008-05-23 09:55:30 +08:00
|
|
|
| shufflevector "(" ^ ConstVal ^ "," ConstVal ^ "," ConstVal ^ ")"
|
2008-06-03 03:47:09 +08:00
|
|
|
| extractvalue "(" ^ ConstVal ^ ConstantIndexList ^ ")"
|
|
|
|
| insertvalue "(" ^ ConstVal ^ "," ConstVal ^ ConstantIndexList ^ ")" ;
|
2008-05-23 06:45:03 +08:00
|
|
|
|
|
|
|
ConstVector ::= ConstVector ^ "," ConstVal | ConstVal ;
|
|
|
|
|
|
|
|
GlobalType ::= global | constant ;
|
|
|
|
|
|
|
|
ThreadLocal ::= - "thread_local" | _ ;
|
|
|
|
|
|
|
|
AliaseeRef ::= ResultTypes SymbolicValueRef
|
|
|
|
| bitcast "(" ^ AliaseeRef to Types ^ ")" ;
|
|
|
|
|
|
|
|
Module ::= +++ DefinitionList | --- _ ;
|
|
|
|
|
|
|
|
DefinitionList ::= - Definition | + DefinitionList Definition ;
|
|
|
|
|
|
|
|
Definition
|
|
|
|
::= ^ ( +++++ define Function
|
|
|
|
| declare FunctionProto
|
|
|
|
| - module asm AsmBlock
|
|
|
|
| OptLocalAssign type Types
|
2009-01-06 07:03:03 +08:00
|
|
|
| OptGlobalAssign GVVisibilityStyle ThreadLocal OptAddrSpace GlobalType
|
2009-01-06 01:29:42 +08:00
|
|
|
ConstVal GlobalVarAttributes
|
|
|
|
| OptGlobalAssign GVInternalLinkage GVVisibilityStyle ThreadLocal OptAddrSpace
|
|
|
|
GlobalType ConstVal GlobalVarAttributes
|
|
|
|
| OptGlobalAssign GVExternalLinkage GVVisibilityStyle ThreadLocal OptAddrSpace
|
|
|
|
GlobalType Types GlobalVarAttributes
|
2008-05-23 06:45:03 +08:00
|
|
|
| OptGlobalAssign GVVisibilityStyle alias AliasLinkage AliaseeRef
|
|
|
|
| target TargetDefinition
|
|
|
|
| deplibs "=" LibrariesDefinition
|
|
|
|
) ^ "\n";
|
|
|
|
|
|
|
|
AsmBlock ::= STRINGCONSTANT ;
|
|
|
|
|
|
|
|
TargetDefinition ::= triple "=" STRINGCONSTANT
|
|
|
|
| datalayout "=" STRINGCONSTANT ;
|
|
|
|
|
2009-01-06 01:29:42 +08:00
|
|
|
LibrariesDefinition ::= "[" ( LibList | _ ) "]";
|
2008-05-23 06:45:03 +08:00
|
|
|
|
2009-01-06 01:29:42 +08:00
|
|
|
LibList ::= LibList ^ "," STRINGCONSTANT | STRINGCONSTANT ;
|
2008-05-23 06:45:03 +08:00
|
|
|
|
|
|
|
ArgListH ::= ArgListH ^ "," Types OptParamAttrs OptLocalName
|
|
|
|
| Types OptParamAttrs OptLocalName ;
|
|
|
|
|
|
|
|
ArgList ::= ArgListH | ArgListH ^ "," "..." | "..." | _ ;
|
|
|
|
|
2009-01-05 11:21:23 +08:00
|
|
|
FunctionHeaderH ::= OptCallingConv OptRetAttrs ResultTypes
|
2009-01-06 01:29:42 +08:00
|
|
|
GlobalName ^ "(" ^ ArgList ^ ")"
|
2009-01-05 11:21:23 +08:00
|
|
|
OptFuncAttrs OptSection OptAlign OptGC ;
|
2008-05-23 06:45:03 +08:00
|
|
|
|
|
|
|
BEGIN ::= ( begin | "{" ) ^ "\n";
|
|
|
|
|
|
|
|
FunctionHeader ::=
|
|
|
|
FunctionDefineLinkage GVVisibilityStyle FunctionHeaderH BEGIN ;
|
|
|
|
|
|
|
|
END ::= ^ ( end | "}" ) ^ "\n";
|
|
|
|
|
|
|
|
Function ::= BasicBlockList END ;
|
|
|
|
|
|
|
|
FunctionProto ::= FunctionDeclareLinkage GVVisibilityStyle FunctionHeaderH ;
|
|
|
|
|
|
|
|
OptSideEffect ::= _ | sideeffect ;
|
|
|
|
|
|
|
|
ConstValueRef ::= ESINT64VAL
|
|
|
|
| EUINT64VAL
|
|
|
|
| FPVAL
|
|
|
|
| true
|
|
|
|
| false
|
|
|
|
| null
|
|
|
|
| undef
|
|
|
|
| zeroinitializer
|
|
|
|
| "<" ConstVector ">"
|
2008-06-09 22:45:02 +08:00
|
|
|
| "[" ConstVector "]"
|
2008-09-16 00:10:51 +08:00
|
|
|
| "[" ^ "]"
|
2008-06-09 22:45:02 +08:00
|
|
|
| "c" ^ STRINGCONSTANT
|
|
|
|
| "{" ConstVector "}"
|
2008-09-16 00:10:51 +08:00
|
|
|
| "{" ^ "}"
|
2008-06-09 22:45:02 +08:00
|
|
|
| "<" ^ "{" ConstVector "}" ^ ">"
|
2008-09-16 00:10:51 +08:00
|
|
|
| "<" ^ "{" ^ "}" ^ ">"
|
2008-05-23 06:45:03 +08:00
|
|
|
| ConstExpr
|
|
|
|
| asm OptSideEffect STRINGCONSTANT ^ "," STRINGCONSTANT ;
|
|
|
|
|
|
|
|
SymbolicValueRef ::= LOCALVALID
|
|
|
|
| GLOBALVALID
|
|
|
|
| LocalName
|
|
|
|
| GlobalName ;
|
|
|
|
|
|
|
|
ValueRef ::= SymbolicValueRef | ConstValueRef;
|
|
|
|
|
|
|
|
ResolvedVal ::= Types ValueRef ;
|
|
|
|
|
|
|
|
ReturnedVal ::= ResolvedVal | ReturnedVal ^ "," ResolvedVal ;
|
|
|
|
|
|
|
|
BasicBlockList ::= BasicBlockList BasicBlock | FunctionHeader BasicBlock ;
|
|
|
|
|
|
|
|
BasicBlock ::= InstructionList OptLocalAssign BBTerminatorInst ;
|
|
|
|
|
|
|
|
InstructionList ::= +++ InstructionList Inst
|
|
|
|
| - _
|
|
|
|
| ^ LABELSTR ^ ":\n" ;
|
|
|
|
|
|
|
|
BBTerminatorInst ::= ^ " " ^
|
|
|
|
( ret ReturnedVal
|
|
|
|
| ret void
|
|
|
|
| br label ValueRef
|
|
|
|
| br INTTYPE ValueRef ^ "," label ValueRef ^ "," label ValueRef
|
|
|
|
| switch IntType ValueRef ^ "," label ValueRef "[" JumpTable "]"
|
2008-09-16 00:10:51 +08:00
|
|
|
| switch IntType ValueRef ^ "," label ValueRef "[" ^ "]"
|
|
|
|
| invoke OptCallingConv ResultTypes ValueRef ^ "(" ^ ParamList ^ ")"
|
|
|
|
OptFuncAttrs
|
2008-05-23 06:45:03 +08:00
|
|
|
to label ValueRef unwind label ValueRef
|
|
|
|
| unwind
|
|
|
|
| unreachable ) ^ "\n";
|
|
|
|
|
|
|
|
JumpTable ::= JumpTable IntType ConstValueRef ^ "," label ValueRef
|
|
|
|
| IntType ConstValueRef ^ "," label ValueRef ;
|
|
|
|
|
|
|
|
Inst ::= ^ " " ^ OptLocalAssign InstVal ^ "\n";
|
|
|
|
|
|
|
|
PHIList ::= Types "[" ValueRef ^ "," ValueRef "]"
|
|
|
|
| PHIList ^ "," "[" ValueRef ^ "," ValueRef "]" ;
|
|
|
|
|
|
|
|
ParamList ::= Types OptParamAttrs ValueRef OptParamAttrs
|
|
|
|
| label OptParamAttrs ValueRef OptParamAttrs
|
|
|
|
| ParamList ^ "," Types OptParamAttrs ValueRef OptParamAttrs
|
|
|
|
| ParamList ^ "," label OptParamAttrs ValueRef OptParamAttrs
|
|
|
|
| - _ ;
|
|
|
|
|
|
|
|
IndexList ::= _ | IndexList ^ "," ResolvedVal ;
|
|
|
|
|
2008-06-03 03:47:09 +08:00
|
|
|
ConstantIndexList ::= "," EUINT64VAL | ConstantIndexList ^ "," EUINT64VAL ;
|
|
|
|
|
2008-05-23 06:45:03 +08:00
|
|
|
OptTailCall ::= tail call | call ;
|
|
|
|
|
|
|
|
InstVal ::=
|
|
|
|
ArithmeticOps Types ValueRef ^ "," ValueRef
|
|
|
|
| LogicalOps Types ValueRef ^ "," ValueRef
|
|
|
|
| icmp IPredicates Types ValueRef ^ "," ValueRef
|
|
|
|
| fcmp FPredicates Types ValueRef ^ "," ValueRef
|
|
|
|
| CastOps ResolvedVal to Types
|
|
|
|
| select ResolvedVal ^ "," ResolvedVal ^ "," ResolvedVal
|
2008-05-24 01:11:55 +08:00
|
|
|
| "va_arg" ResolvedVal ^ "," Types
|
2008-05-23 06:45:03 +08:00
|
|
|
| extractelement ResolvedVal ^ "," ResolvedVal
|
|
|
|
| insertelement ResolvedVal ^ "," ResolvedVal ^ "," ResolvedVal
|
|
|
|
| shufflevector ResolvedVal ^ "," ResolvedVal ^ "," ResolvedVal
|
|
|
|
| phi PHIList
|
2008-09-16 00:10:51 +08:00
|
|
|
| OptTailCall OptCallingConv ResultTypes ValueRef ^ "(" ^ ParamList ^ ")"
|
2008-05-23 06:45:03 +08:00
|
|
|
OptFuncAttrs
|
|
|
|
| MemoryInst ;
|
|
|
|
|
|
|
|
OptVolatile ::= - volatile | _ ;
|
2009-07-23 06:45:30 +08:00
|
|
|
OptExact ::= - exact | _ ;
|
|
|
|
OptNSW ::= - nsw | _ ;
|
|
|
|
OptNUW ::= - nuw | _ ;
|
2010-05-04 08:13:24 +08:00
|
|
|
OptNW ::= OptNUW OptNSW | OptNSW OptNUW ;
|
2009-07-28 05:55:32 +08:00
|
|
|
OptInBounds ::= - inbounds | _ ;
|
2008-05-23 06:45:03 +08:00
|
|
|
|
|
|
|
MemoryInst ::= malloc Types OptCAlign
|
|
|
|
| malloc Types ^ "," INTTYPE ValueRef OptCAlign
|
|
|
|
| alloca Types OptCAlign
|
|
|
|
| alloca Types ^ "," INTTYPE ValueRef OptCAlign
|
|
|
|
| free ResolvedVal
|
|
|
|
| OptVolatile load Types ValueRef OptCAlign
|
|
|
|
| OptVolatile store ResolvedVal ^ "," Types ValueRef OptCAlign
|
|
|
|
| getresult Types ValueRef ^ "," EUINT64VAL
|
2009-07-28 05:55:32 +08:00
|
|
|
| getelementptr OptInBounds Types ValueRef IndexList
|
2008-06-03 03:47:09 +08:00
|
|
|
| extractvalue Types ValueRef ^ ConstantIndexList
|
|
|
|
| insertvalue Types ValueRef ^ "," Types ValueRef ^ ConstantIndexList ;
|