Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 1 | (* |
| 2 | |
| 3 | polygen grammar for LLVM assembly language. |
| 4 | |
| 5 | This file defines an LLVM assembly language grammar for polygen, |
| 6 | which is a tool for generating random text based on a grammar. |
| 7 | It is strictly syntax-based, and makes no attempt to generate |
| 8 | IR that is semantically valid. Most of the IR produced doesn't |
| 9 | pass the Verifier. |
| 10 | |
Dan Gohman | a285852 | 2010-08-04 17:01:59 +0000 | [diff] [blame] | 11 | TODO: Metadata, in all its forms |
Dan Gohman | a285852 | 2010-08-04 17:01:59 +0000 | [diff] [blame] | 12 | |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 13 | *) |
| 14 | |
| 15 | I ::= "title: LLVM assembly language\n" |
| 16 | ^ "status: experimental\n" |
| 17 | ^ "audience: LLVM developers\n" |
| 18 | ; |
| 19 | |
| 20 | S ::= Module ; |
| 21 | |
| 22 | (* |
| 23 | Define rules for non-keyword tokens. This is currently just a bunch |
| 24 | of hacks. They don't cover many valid forms of tokens, and they also |
| 25 | generate some invalid forms of tokens. The LLVM parser has custom |
| 26 | C++ code to lex these; custom C++ code for emitting them would be |
| 27 | convenient, but polygen doesn't support that. |
| 28 | *) |
| 29 | NonZeroDecimalDigit ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ; |
| 30 | DecimalDigit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ; |
| 31 | DecimalDigitSeq ::= DecimalDigit [^ DecimalDigitSeq ]; |
| 32 | HexDigit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 33 | | a | b | c | d | e | f ; |
| 34 | HexDigitSeq ::= HexDigit [^ HexDigitSeq ]; |
| 35 | StringChar ::= a | b | c | d | e | f | g | h | i | j | k | l | m |
| 36 | | n | o | p | q | r | s | t | u | v | w | x | y | z ; |
| 37 | StringConstantSeq ::= StringChar [^ StringConstantSeq ]; |
| 38 | StringConstant ::= StringChar [^ StringConstantSeq ]; |
| 39 | EUINT64VAL ::= NonZeroDecimalDigit [^ DecimalDigitSeq ]; |
| 40 | ESINT64VAL ::= [ "-" ] ^ EUINT64VAL ; |
| 41 | EUAPINTVAL ::= EUINT64VAL ; |
| 42 | ESAPINTVAL ::= ESINT64VAL ; |
| 43 | LOCALVALID ::= "%" ^ DecimalDigitSeq ; |
| 44 | GLOBALVALID ::= "@" ^ DecimalDigitSeq ; |
| 45 | INTTYPE ::= "i" ^ EUINT64VAL ; |
| 46 | GLOBALVAR ::= "@" ^ StringConstant ; |
| 47 | LOCALVAR ::= "%" ^ StringConstant ; |
| 48 | STRINGCONSTANT ::= "\"" ^ StringConstant ^ "\"" ; |
| 49 | ATSTRINGCONSTANT ::= "@" ^ STRINGCONSTANT ; |
| 50 | PCTSTRINGCONSTANT ::= "%" ^ STRINGCONSTANT ; |
| 51 | LABELSTR ::= StringConstant ; |
| 52 | FPVAL ::= ESAPINTVAL ^ "." ^ EUAPINTVAL | "0x" ^ HexDigitSeq ; |
| 53 | |
| 54 | (* |
| 55 | The rest of this file is derived directly from llvmAsmParser.y. |
| 56 | *) |
| 57 | |
Dan Gohman | bfacb7e | 2009-07-22 22:45:30 +0000 | [diff] [blame] | 58 | ArithmeticOps ::= + OptNW add | fadd | OptNW sub | fsub | OptNW mul | fmul | |
| 59 | udiv | OptExact sdiv | fdiv | urem | srem | frem ; |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 60 | LogicalOps ::= shl | lshr | ashr | and | or | xor; |
| 61 | CastOps ::= trunc | zext | sext | fptrunc | fpext | bitcast | |
| 62 | uitofp | sitofp | fptoui | fptosi | inttoptr | ptrtoint ; |
| 63 | |
| 64 | IPredicates ::= eq | ne | slt | sgt | sle | sge | ult | ugt | ule | uge ; |
| 65 | |
| 66 | FPredicates ::= oeq | one | olt | ogt | ole | oge | ord | uno | ueq | une |
| 67 | | ult | ugt | ule | uge | true | false ; |
| 68 | |
| 69 | IntType ::= INTTYPE; |
| 70 | FPType ::= float | double | "ppc_fp128" | fp128 | "x86_fp80"; |
| 71 | |
| 72 | LocalName ::= LOCALVAR | STRINGCONSTANT | PCTSTRINGCONSTANT ; |
| 73 | OptLocalName ::= LocalName | _ ; |
| 74 | |
Dan Gohman | 8f56eba | 2009-01-05 17:29:42 +0000 | [diff] [blame] | 75 | OptAddrSpace ::= - addrspace ^ "(" ^ EUINT64VAL ^ ")" | _ ; |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 76 | |
| 77 | OptLocalAssign ::= LocalName "=" | _ ; |
| 78 | |
| 79 | GlobalName ::= GLOBALVAR | ATSTRINGCONSTANT ; |
| 80 | |
| 81 | OptGlobalAssign ::= GlobalAssign | _ ; |
| 82 | |
| 83 | GlobalAssign ::= GlobalName "=" ; |
| 84 | |
| 85 | GVInternalLinkage |
| 86 | ::= + internal |
| 87 | | weak |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 88 | | "weak_odr" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 89 | | linkonce |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 90 | | "linkonce_odr" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 91 | | appending |
| 92 | | dllexport |
| 93 | | common |
Dan Gohman | 923a579 | 2009-07-17 01:07:45 +0000 | [diff] [blame] | 94 | | private |
Dan Gohman | a285852 | 2010-08-04 17:01:59 +0000 | [diff] [blame] | 95 | | "linker_private" |
| 96 | | "linker_private_weak" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 97 | ; |
| 98 | |
| 99 | GVExternalLinkage |
| 100 | ::= dllimport |
| 101 | | "extern_weak" |
| 102 | | + external |
| 103 | ; |
| 104 | |
| 105 | GVVisibilityStyle |
| 106 | ::= + _ |
| 107 | | default |
| 108 | | hidden |
| 109 | | protected |
| 110 | ; |
| 111 | |
| 112 | FunctionDeclareLinkage |
| 113 | ::= + _ |
| 114 | | dllimport |
| 115 | | "extern_weak" |
| 116 | ; |
| 117 | |
| 118 | FunctionDefineLinkage |
| 119 | ::= + _ |
| 120 | | internal |
| 121 | | linkonce |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 122 | | "linkonce_odr" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 123 | | weak |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 124 | | "weak_odr" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 125 | | dllexport |
| 126 | ; |
| 127 | |
Duncan Sands | 667d4b8 | 2009-03-07 15:45:40 +0000 | [diff] [blame] | 128 | AliasLinkage ::= + _ | weak | "weak_odr" | internal ; |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 129 | |
| 130 | OptCallingConv ::= + _ | |
| 131 | ccc | |
| 132 | fastcc | |
| 133 | coldcc | |
| 134 | "x86_stdcallcc" | |
| 135 | "x86_fastcallcc" | |
| 136 | cc EUINT64VAL ; |
| 137 | |
| 138 | ParamAttr ::= zeroext |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 139 | | signext |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 140 | | inreg |
| 141 | | sret |
| 142 | | noalias |
Dan Gohman | 571238a | 2009-01-05 03:21:23 +0000 | [diff] [blame] | 143 | | nocapture |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 144 | | byval |
| 145 | | nest |
| 146 | | align EUINT64VAL |
| 147 | ; |
| 148 | |
| 149 | OptParamAttrs ::= + _ | OptParamAttrs ParamAttr ; |
| 150 | |
Dan Gohman | 571238a | 2009-01-05 03:21:23 +0000 | [diff] [blame] | 151 | RetAttr ::= inreg |
| 152 | | zeroext |
| 153 | | signext |
| 154 | | noalias |
| 155 | ; |
| 156 | |
| 157 | OptRetAttrs ::= _ |
| 158 | | OptRetAttrs RetAttr |
| 159 | ; |
| 160 | |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 161 | FuncAttr ::= noreturn |
| 162 | | nounwind |
Dan Gohman | 571238a | 2009-01-05 03:21:23 +0000 | [diff] [blame] | 163 | | inreg |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 164 | | zeroext |
| 165 | | signext |
| 166 | | readnone |
| 167 | | readonly |
Jakob Stoklund Olesen | 570a4a5 | 2010-02-06 01:16:28 +0000 | [diff] [blame] | 168 | | inlinehint |
Dan Gohman | c235a0c | 2010-03-01 17:53:39 +0000 | [diff] [blame] | 169 | | alignstack |
Dan Gohman | 571238a | 2009-01-05 03:21:23 +0000 | [diff] [blame] | 170 | | noinline |
| 171 | | alwaysinline |
| 172 | | optsize |
| 173 | | ssp |
| 174 | | sspreq |
Rafael Espindola | b3c4e26 | 2011-10-04 03:08:43 +0000 | [diff] [blame] | 175 | | returns_twice |
John McCall | 3a3465b | 2011-06-15 20:36:13 +0000 | [diff] [blame] | 176 | | nonlazybind |
Kostya Serebryany | 8eec41f | 2013-02-26 06:58:09 +0000 | [diff] [blame] | 177 | | sanitize_address |
| 178 | | sanitize_thread |
| 179 | | sanitize_memory |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 180 | ; |
| 181 | |
| 182 | OptFuncAttrs ::= + _ | OptFuncAttrs FuncAttr ; |
| 183 | |
| 184 | OptGC ::= + _ | gc STRINGCONSTANT ; |
| 185 | |
| 186 | OptAlign ::= + _ | align EUINT64VAL ; |
| 187 | OptCAlign ::= + _ | ^ "," align EUINT64VAL ; |
| 188 | |
| 189 | SectionString ::= section STRINGCONSTANT ; |
| 190 | |
| 191 | OptSection ::= + _ | SectionString ; |
| 192 | |
| 193 | GlobalVarAttributes ::= + _ | ^ "," GlobalVarAttribute GlobalVarAttributes ; |
| 194 | GlobalVarAttribute ::= SectionString | align EUINT64VAL ; |
| 195 | |
| 196 | PrimType ::= INTTYPE | float | double | "ppc_fp128" | fp128 | "x86_fp80" |
| 197 | | - label ; |
| 198 | |
| 199 | Types |
| 200 | ::= opaque |
| 201 | | PrimType |
| 202 | | Types OptAddrSpace ^ "*" |
| 203 | | SymbolicValueRef |
| 204 | | "\\" ^ EUINT64VAL |
| 205 | | Types "(" ^ ArgTypeListI ^ ")" OptFuncAttrs |
| 206 | | void "(" ^ ArgTypeListI ^ ")" OptFuncAttrs |
| 207 | | "[" ^ EUINT64VAL "x" Types ^ "]" |
| 208 | | "<" ^ EUINT64VAL "x" Types ^ ">" |
| 209 | | "{" TypeListI "}" |
Dan Gohman | 0d58eb6 | 2008-09-15 16:10:51 +0000 | [diff] [blame] | 210 | | "{" ^ "}" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 211 | | "<" ^ "{" TypeListI "}" ^ ">" |
Dan Gohman | 0d58eb6 | 2008-09-15 16:10:51 +0000 | [diff] [blame] | 212 | | "<" ^ "{" ^ "}" ^ ">" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 213 | ; |
| 214 | |
| 215 | ArgType ::= Types OptParamAttrs ; |
| 216 | |
| 217 | ResultTypes ::= Types | void ; |
| 218 | |
| 219 | ArgTypeList ::= ArgType | ArgTypeList ^ "," ArgType ; |
| 220 | |
| 221 | ArgTypeListI ::= ArgTypeList | ArgTypeList ^ "," "..." | "..." | _ ; |
| 222 | |
| 223 | TypeListI ::= Types | TypeListI ^ "," Types ; |
| 224 | |
| 225 | ConstVal::= Types "[" ^ ConstVector ^ "]" |
Dan Gohman | 0d58eb6 | 2008-09-15 16:10:51 +0000 | [diff] [blame] | 226 | | Types "[" ^ "]" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 227 | | Types "c" ^ STRINGCONSTANT |
| 228 | | Types "<" ^ ConstVector ^ ">" |
| 229 | | Types "{" ConstVector "}" |
Dan Gohman | 0d58eb6 | 2008-09-15 16:10:51 +0000 | [diff] [blame] | 230 | | Types "{" ^ "}" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 231 | | Types "<" ^ "{" ConstVector "}" ^ ">" |
Dan Gohman | 0d58eb6 | 2008-09-15 16:10:51 +0000 | [diff] [blame] | 232 | | Types "<" ^ "{" ^ "}" ^ ">" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 233 | | Types null |
| 234 | | Types undef |
| 235 | | Types SymbolicValueRef |
| 236 | | Types ConstExpr |
| 237 | | Types zeroinitializer |
Dan Gohman | 571238a | 2009-01-05 03:21:23 +0000 | [diff] [blame] | 238 | | Types ESINT64VAL |
| 239 | | Types ESAPINTVAL |
| 240 | | Types EUINT64VAL |
| 241 | | Types EUAPINTVAL |
| 242 | | Types true |
| 243 | | Types false |
| 244 | | Types FPVAL ; |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 245 | |
| 246 | ConstExpr::= CastOps "(" ^ ConstVal to Types ^ ")" |
Dan Gohman | 224251d | 2009-07-27 21:55:32 +0000 | [diff] [blame] | 247 | | getelementptr OptInBounds "(" ^ ConstVal IndexList ^ ")" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 248 | | select "(" ^ ConstVal ^ "," ConstVal ^ "," ConstVal ^ ")" |
| 249 | | ArithmeticOps "(" ^ ConstVal ^ "," ConstVal ^ ")" |
| 250 | | LogicalOps "(" ^ ConstVal ^ "," ConstVal ^ ")" |
| 251 | | icmp IPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")" |
| 252 | | fcmp FPredicates "(" ^ ConstVal ^ "," ConstVal ^ ")" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 253 | | extractelement "(" ^ ConstVal ^ "," ConstVal ^ ")" |
| 254 | | insertelement "(" ^ ConstVal ^ "," ConstVal ^ "," ConstVal ^ ")" |
Dan Gohman | e4977cf | 2008-05-23 01:55:30 +0000 | [diff] [blame] | 255 | | shufflevector "(" ^ ConstVal ^ "," ConstVal ^ "," ConstVal ^ ")" |
Dan Gohman | 34e71fe | 2008-06-02 19:47:09 +0000 | [diff] [blame] | 256 | | extractvalue "(" ^ ConstVal ^ ConstantIndexList ^ ")" |
| 257 | | insertvalue "(" ^ ConstVal ^ "," ConstVal ^ ConstantIndexList ^ ")" ; |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 258 | |
| 259 | ConstVector ::= ConstVector ^ "," ConstVal | ConstVal ; |
| 260 | |
| 261 | GlobalType ::= global | constant ; |
| 262 | |
| 263 | ThreadLocal ::= - "thread_local" | _ ; |
| 264 | |
| 265 | AliaseeRef ::= ResultTypes SymbolicValueRef |
| 266 | | bitcast "(" ^ AliaseeRef to Types ^ ")" ; |
| 267 | |
| 268 | Module ::= +++ DefinitionList | --- _ ; |
| 269 | |
| 270 | DefinitionList ::= - Definition | + DefinitionList Definition ; |
| 271 | |
| 272 | Definition |
| 273 | ::= ^ ( +++++ define Function |
| 274 | | declare FunctionProto |
| 275 | | - module asm AsmBlock |
| 276 | | OptLocalAssign type Types |
Dan Gohman | de0e7f2 | 2009-01-05 23:03:03 +0000 | [diff] [blame] | 277 | | OptGlobalAssign GVVisibilityStyle ThreadLocal OptAddrSpace GlobalType |
Dan Gohman | 8f56eba | 2009-01-05 17:29:42 +0000 | [diff] [blame] | 278 | ConstVal GlobalVarAttributes |
| 279 | | OptGlobalAssign GVInternalLinkage GVVisibilityStyle ThreadLocal OptAddrSpace |
| 280 | GlobalType ConstVal GlobalVarAttributes |
| 281 | | OptGlobalAssign GVExternalLinkage GVVisibilityStyle ThreadLocal OptAddrSpace |
| 282 | GlobalType Types GlobalVarAttributes |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 283 | | OptGlobalAssign GVVisibilityStyle alias AliasLinkage AliaseeRef |
| 284 | | target TargetDefinition |
| 285 | | deplibs "=" LibrariesDefinition |
| 286 | ) ^ "\n"; |
| 287 | |
| 288 | AsmBlock ::= STRINGCONSTANT ; |
| 289 | |
| 290 | TargetDefinition ::= triple "=" STRINGCONSTANT |
| 291 | | datalayout "=" STRINGCONSTANT ; |
| 292 | |
Dan Gohman | 8f56eba | 2009-01-05 17:29:42 +0000 | [diff] [blame] | 293 | LibrariesDefinition ::= "[" ( LibList | _ ) "]"; |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 294 | |
Dan Gohman | 8f56eba | 2009-01-05 17:29:42 +0000 | [diff] [blame] | 295 | LibList ::= LibList ^ "," STRINGCONSTANT | STRINGCONSTANT ; |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 296 | |
| 297 | ArgListH ::= ArgListH ^ "," Types OptParamAttrs OptLocalName |
| 298 | | Types OptParamAttrs OptLocalName ; |
| 299 | |
| 300 | ArgList ::= ArgListH | ArgListH ^ "," "..." | "..." | _ ; |
| 301 | |
Dan Gohman | 571238a | 2009-01-05 03:21:23 +0000 | [diff] [blame] | 302 | FunctionHeaderH ::= OptCallingConv OptRetAttrs ResultTypes |
Dan Gohman | 8f56eba | 2009-01-05 17:29:42 +0000 | [diff] [blame] | 303 | GlobalName ^ "(" ^ ArgList ^ ")" |
Dan Gohman | 571238a | 2009-01-05 03:21:23 +0000 | [diff] [blame] | 304 | OptFuncAttrs OptSection OptAlign OptGC ; |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 305 | |
| 306 | BEGIN ::= ( begin | "{" ) ^ "\n"; |
| 307 | |
| 308 | FunctionHeader ::= |
| 309 | FunctionDefineLinkage GVVisibilityStyle FunctionHeaderH BEGIN ; |
| 310 | |
| 311 | END ::= ^ ( end | "}" ) ^ "\n"; |
| 312 | |
| 313 | Function ::= BasicBlockList END ; |
| 314 | |
| 315 | FunctionProto ::= FunctionDeclareLinkage GVVisibilityStyle FunctionHeaderH ; |
| 316 | |
| 317 | OptSideEffect ::= _ | sideeffect ; |
| 318 | |
| 319 | ConstValueRef ::= ESINT64VAL |
| 320 | | EUINT64VAL |
| 321 | | FPVAL |
| 322 | | true |
| 323 | | false |
| 324 | | null |
| 325 | | undef |
| 326 | | zeroinitializer |
| 327 | | "<" ConstVector ">" |
Dan Gohman | f910eaa | 2008-06-09 14:45:02 +0000 | [diff] [blame] | 328 | | "[" ConstVector "]" |
Dan Gohman | 0d58eb6 | 2008-09-15 16:10:51 +0000 | [diff] [blame] | 329 | | "[" ^ "]" |
Dan Gohman | f910eaa | 2008-06-09 14:45:02 +0000 | [diff] [blame] | 330 | | "c" ^ STRINGCONSTANT |
| 331 | | "{" ConstVector "}" |
Dan Gohman | 0d58eb6 | 2008-09-15 16:10:51 +0000 | [diff] [blame] | 332 | | "{" ^ "}" |
Dan Gohman | f910eaa | 2008-06-09 14:45:02 +0000 | [diff] [blame] | 333 | | "<" ^ "{" ConstVector "}" ^ ">" |
Dan Gohman | 0d58eb6 | 2008-09-15 16:10:51 +0000 | [diff] [blame] | 334 | | "<" ^ "{" ^ "}" ^ ">" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 335 | | ConstExpr |
| 336 | | asm OptSideEffect STRINGCONSTANT ^ "," STRINGCONSTANT ; |
| 337 | |
| 338 | SymbolicValueRef ::= LOCALVALID |
| 339 | | GLOBALVALID |
| 340 | | LocalName |
| 341 | | GlobalName ; |
| 342 | |
| 343 | ValueRef ::= SymbolicValueRef | ConstValueRef; |
| 344 | |
| 345 | ResolvedVal ::= Types ValueRef ; |
| 346 | |
| 347 | ReturnedVal ::= ResolvedVal | ReturnedVal ^ "," ResolvedVal ; |
| 348 | |
| 349 | BasicBlockList ::= BasicBlockList BasicBlock | FunctionHeader BasicBlock ; |
| 350 | |
| 351 | BasicBlock ::= InstructionList OptLocalAssign BBTerminatorInst ; |
| 352 | |
| 353 | InstructionList ::= +++ InstructionList Inst |
| 354 | | - _ |
| 355 | | ^ LABELSTR ^ ":\n" ; |
| 356 | |
| 357 | BBTerminatorInst ::= ^ " " ^ |
| 358 | ( ret ReturnedVal |
| 359 | | ret void |
| 360 | | br label ValueRef |
| 361 | | br INTTYPE ValueRef ^ "," label ValueRef ^ "," label ValueRef |
| 362 | | switch IntType ValueRef ^ "," label ValueRef "[" JumpTable "]" |
Dan Gohman | 0d58eb6 | 2008-09-15 16:10:51 +0000 | [diff] [blame] | 363 | | switch IntType ValueRef ^ "," label ValueRef "[" ^ "]" |
| 364 | | invoke OptCallingConv ResultTypes ValueRef ^ "(" ^ ParamList ^ ")" |
| 365 | OptFuncAttrs |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 366 | to label ValueRef unwind label ValueRef |
| 367 | | unwind |
| 368 | | unreachable ) ^ "\n"; |
| 369 | |
| 370 | JumpTable ::= JumpTable IntType ConstValueRef ^ "," label ValueRef |
| 371 | | IntType ConstValueRef ^ "," label ValueRef ; |
| 372 | |
| 373 | Inst ::= ^ " " ^ OptLocalAssign InstVal ^ "\n"; |
| 374 | |
| 375 | PHIList ::= Types "[" ValueRef ^ "," ValueRef "]" |
| 376 | | PHIList ^ "," "[" ValueRef ^ "," ValueRef "]" ; |
| 377 | |
| 378 | ParamList ::= Types OptParamAttrs ValueRef OptParamAttrs |
| 379 | | label OptParamAttrs ValueRef OptParamAttrs |
| 380 | | ParamList ^ "," Types OptParamAttrs ValueRef OptParamAttrs |
| 381 | | ParamList ^ "," label OptParamAttrs ValueRef OptParamAttrs |
| 382 | | - _ ; |
| 383 | |
| 384 | IndexList ::= _ | IndexList ^ "," ResolvedVal ; |
| 385 | |
Dan Gohman | 34e71fe | 2008-06-02 19:47:09 +0000 | [diff] [blame] | 386 | ConstantIndexList ::= "," EUINT64VAL | ConstantIndexList ^ "," EUINT64VAL ; |
| 387 | |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 388 | OptTailCall ::= tail call | call ; |
| 389 | |
| 390 | InstVal ::= |
| 391 | ArithmeticOps Types ValueRef ^ "," ValueRef |
| 392 | | LogicalOps Types ValueRef ^ "," ValueRef |
| 393 | | icmp IPredicates Types ValueRef ^ "," ValueRef |
| 394 | | fcmp FPredicates Types ValueRef ^ "," ValueRef |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 395 | | CastOps ResolvedVal to Types |
| 396 | | select ResolvedVal ^ "," ResolvedVal ^ "," ResolvedVal |
Dan Gohman | b737a64 | 2008-05-23 17:11:55 +0000 | [diff] [blame] | 397 | | "va_arg" ResolvedVal ^ "," Types |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 398 | | extractelement ResolvedVal ^ "," ResolvedVal |
| 399 | | insertelement ResolvedVal ^ "," ResolvedVal ^ "," ResolvedVal |
| 400 | | shufflevector ResolvedVal ^ "," ResolvedVal ^ "," ResolvedVal |
| 401 | | phi PHIList |
Dan Gohman | 0d58eb6 | 2008-09-15 16:10:51 +0000 | [diff] [blame] | 402 | | OptTailCall OptCallingConv ResultTypes ValueRef ^ "(" ^ ParamList ^ ")" |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 403 | OptFuncAttrs |
| 404 | | MemoryInst ; |
| 405 | |
| 406 | OptVolatile ::= - volatile | _ ; |
Dan Gohman | bfacb7e | 2009-07-22 22:45:30 +0000 | [diff] [blame] | 407 | OptExact ::= - exact | _ ; |
| 408 | OptNSW ::= - nsw | _ ; |
| 409 | OptNUW ::= - nuw | _ ; |
Dan Gohman | d622b0b | 2010-05-04 00:13:24 +0000 | [diff] [blame] | 410 | OptNW ::= OptNUW OptNSW | OptNSW OptNUW ; |
Dan Gohman | 224251d | 2009-07-27 21:55:32 +0000 | [diff] [blame] | 411 | OptInBounds ::= - inbounds | _ ; |
Dan Gohman | 890c31c | 2008-05-22 22:45:03 +0000 | [diff] [blame] | 412 | |
| 413 | MemoryInst ::= malloc Types OptCAlign |
| 414 | | malloc Types ^ "," INTTYPE ValueRef OptCAlign |
| 415 | | alloca Types OptCAlign |
| 416 | | alloca Types ^ "," INTTYPE ValueRef OptCAlign |
| 417 | | free ResolvedVal |
| 418 | | OptVolatile load Types ValueRef OptCAlign |
| 419 | | OptVolatile store ResolvedVal ^ "," Types ValueRef OptCAlign |
| 420 | | getresult Types ValueRef ^ "," EUINT64VAL |
Dan Gohman | 224251d | 2009-07-27 21:55:32 +0000 | [diff] [blame] | 421 | | getelementptr OptInBounds Types ValueRef IndexList |
Dan Gohman | 34e71fe | 2008-06-02 19:47:09 +0000 | [diff] [blame] | 422 | | extractvalue Types ValueRef ^ ConstantIndexList |
| 423 | | insertvalue Types ValueRef ^ "," Types ValueRef ^ ConstantIndexList ; |