mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
d15cd32b9f
These linkages were introduced some time ago, but it was never very clear what exactly their semantics were or what they should be used for. Some investigation found these uses: * utf-16 strings in clang. * non-unnamed_addr strings produced by the sanitizers. It turns out they were just working around a more fundamental problem. For some sections a MachO linker needs a symbol in order to split the section into atoms, and llvm had no idea that was the case. I fixed that in r201700 and it is now safe to use the private linkage. When the object ends up in a section that requires symbols, llvm will use a 'l' prefix instead of a 'L' prefix and things just work. With that, these linkages were already dead, but there was a potential future user in the objc metadata information. I am still looking at CGObjcMac.cpp, but at this point I am convinced that linker_private and linker_private_weak are not what they need. The objc uses are currently split in * Regular symbols (no '\01' prefix). LLVM already directly provides whatever semantics they need. * Uses of a private name (start with "\01L" or "\01l") and private linkage. We can drop the "\01L" and "\01l" prefixes as soon as llvm agrees with clang on L being ok or not for a given section. I have two patches in code review for this. * Uses of private name and weak linkage. The last case is the one that one could think would fit one of these linkages. That is not the case. The semantics are * the linker will merge these symbol by *name*. * the linker will hide them in the final DSO. Given that the merging is done by name, any of the private (or internal) linkages would be a bad match. They allow llvm to rename the symbols, and that is really not what we want. From the llvm point of view, these objects should really be (linkonce|weak)(_odr)?. For now, just keeping the "\01l" prefix is probably the best for these symbols. If we one day want to have a more direct support in llvm, IMHO what we should add is not a linkage, it is just a hidden_symbol attribute. It would be applicable to multiple linkages. For example, on weak it would produce the current behavior we have for objc metadata. On internal, it would be equivalent to private (and we should then remove private). llvm-svn: 203866
422 lines
12 KiB
Plaintext
422 lines
12 KiB
Plaintext
(*
|
|
|
|
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.
|
|
|
|
TODO: Metadata, in all its forms
|
|
|
|
*)
|
|
|
|
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.
|
|
*)
|
|
|
|
ArithmeticOps ::= + OptNW add | fadd | OptNW sub | fsub | OptNW mul | fmul |
|
|
udiv | OptExact sdiv | fdiv | urem | srem | frem ;
|
|
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;
|
|
FPType ::= float | double | "ppc_fp128" | fp128 | "x86_fp80";
|
|
|
|
LocalName ::= LOCALVAR | STRINGCONSTANT | PCTSTRINGCONSTANT ;
|
|
OptLocalName ::= LocalName | _ ;
|
|
|
|
OptAddrSpace ::= - addrspace ^ "(" ^ EUINT64VAL ^ ")" | _ ;
|
|
|
|
OptLocalAssign ::= LocalName "=" | _ ;
|
|
|
|
GlobalName ::= GLOBALVAR | ATSTRINGCONSTANT ;
|
|
|
|
OptGlobalAssign ::= GlobalAssign | _ ;
|
|
|
|
GlobalAssign ::= GlobalName "=" ;
|
|
|
|
GVInternalLinkage
|
|
::= + internal
|
|
| weak
|
|
| "weak_odr"
|
|
| linkonce
|
|
| "linkonce_odr"
|
|
| appending
|
|
| dllexport
|
|
| common
|
|
| private
|
|
;
|
|
|
|
GVExternalLinkage
|
|
::= dllimport
|
|
| "extern_weak"
|
|
| + external
|
|
;
|
|
|
|
GVVisibilityStyle
|
|
::= + _
|
|
| default
|
|
| hidden
|
|
| protected
|
|
;
|
|
|
|
FunctionDeclareLinkage
|
|
::= + _
|
|
| dllimport
|
|
| "extern_weak"
|
|
;
|
|
|
|
FunctionDefineLinkage
|
|
::= + _
|
|
| internal
|
|
| linkonce
|
|
| "linkonce_odr"
|
|
| weak
|
|
| "weak_odr"
|
|
| dllexport
|
|
;
|
|
|
|
AliasLinkage ::= + _ | weak | "weak_odr" | internal ;
|
|
|
|
OptCallingConv ::= + _ |
|
|
ccc |
|
|
fastcc |
|
|
coldcc |
|
|
"x86_stdcallcc" |
|
|
"x86_fastcallcc" |
|
|
cc EUINT64VAL ;
|
|
|
|
ParamAttr ::= zeroext
|
|
| signext
|
|
| inreg
|
|
| sret
|
|
| noalias
|
|
| nocapture
|
|
| byval
|
|
| nest
|
|
| align EUINT64VAL
|
|
;
|
|
|
|
OptParamAttrs ::= + _ | OptParamAttrs ParamAttr ;
|
|
|
|
RetAttr ::= inreg
|
|
| zeroext
|
|
| signext
|
|
| noalias
|
|
;
|
|
|
|
OptRetAttrs ::= _
|
|
| OptRetAttrs RetAttr
|
|
;
|
|
|
|
FuncAttr ::= noreturn
|
|
| nounwind
|
|
| inreg
|
|
| zeroext
|
|
| signext
|
|
| readnone
|
|
| readonly
|
|
| inlinehint
|
|
| alignstack
|
|
| noinline
|
|
| alwaysinline
|
|
| optsize
|
|
| ssp
|
|
| sspreq
|
|
| returns_twice
|
|
| nonlazybind
|
|
| sanitize_address
|
|
| sanitize_thread
|
|
| sanitize_memory
|
|
;
|
|
|
|
OptFuncAttrs ::= + _ | OptFuncAttrs FuncAttr ;
|
|
|
|
OptGC ::= + _ | gc STRINGCONSTANT ;
|
|
|
|
OptAlign ::= + _ | align EUINT64VAL ;
|
|
OptCAlign ::= + _ | ^ "," align EUINT64VAL ;
|
|
|
|
SectionString ::= section STRINGCONSTANT ;
|
|
|
|
OptSection ::= + _ | SectionString ;
|
|
|
|
GlobalVarAttributes ::= + _ | ^ "," GlobalVarAttribute GlobalVarAttributes ;
|
|
GlobalVarAttribute ::= SectionString | align EUINT64VAL ;
|
|
|
|
PrimType ::= INTTYPE | float | double | "ppc_fp128" | fp128 | "x86_fp80"
|
|
| - label ;
|
|
|
|
Types
|
|
::= opaque
|
|
| PrimType
|
|
| Types OptAddrSpace ^ "*"
|
|
| SymbolicValueRef
|
|
| "\\" ^ EUINT64VAL
|
|
| Types "(" ^ ArgTypeListI ^ ")" OptFuncAttrs
|
|
| void "(" ^ ArgTypeListI ^ ")" OptFuncAttrs
|
|
| "[" ^ EUINT64VAL "x" Types ^ "]"
|
|
| "<" ^ EUINT64VAL "x" Types ^ ">"
|
|
| "{" TypeListI "}"
|
|
| "{" ^ "}"
|
|
| "<" ^ "{" TypeListI "}" ^ ">"
|
|
| "<" ^ "{" ^ "}" ^ ">"
|
|
;
|
|
|
|
ArgType ::= Types OptParamAttrs ;
|
|
|
|
ResultTypes ::= Types | void ;
|
|
|
|
ArgTypeList ::= ArgType | ArgTypeList ^ "," ArgType ;
|
|
|
|
ArgTypeListI ::= ArgTypeList | ArgTypeList ^ "," "..." | "..." | _ ;
|
|
|
|
TypeListI ::= Types | TypeListI ^ "," Types ;
|
|
|
|
ConstVal::= Types "[" ^ ConstVector ^ "]"
|
|
| Types "[" ^ "]"
|
|
| Types "c" ^ STRINGCONSTANT
|
|
| Types "<" ^ ConstVector ^ ">"
|
|
| Types "{" ConstVector "}"
|
|
| Types "{" ^ "}"
|
|
| Types "<" ^ "{" ConstVector "}" ^ ">"
|
|
| Types "<" ^ "{" ^ "}" ^ ">"
|
|
| Types null
|
|
| Types undef
|
|
| Types SymbolicValueRef
|
|
| Types ConstExpr
|
|
| Types zeroinitializer
|
|
| Types ESINT64VAL
|
|
| Types ESAPINTVAL
|
|
| Types EUINT64VAL
|
|
| Types EUAPINTVAL
|
|
| Types true
|
|
| Types false
|
|
| Types FPVAL ;
|
|
|
|
ConstExpr::= CastOps "(" ^ ConstVal to Types ^ ")"
|
|
| getelementptr OptInBounds "(" ^ ConstVal IndexList ^ ")"
|
|
| 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 ^ ")"
|
|
| shufflevector "(" ^ ConstVal ^ "," ConstVal ^ "," ConstVal ^ ")"
|
|
| extractvalue "(" ^ ConstVal ^ ConstantIndexList ^ ")"
|
|
| insertvalue "(" ^ ConstVal ^ "," ConstVal ^ ConstantIndexList ^ ")" ;
|
|
|
|
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
|
|
| OptGlobalAssign GVVisibilityStyle ThreadLocal OptAddrSpace GlobalType
|
|
ConstVal GlobalVarAttributes
|
|
| OptGlobalAssign GVInternalLinkage GVVisibilityStyle ThreadLocal OptAddrSpace
|
|
GlobalType ConstVal GlobalVarAttributes
|
|
| OptGlobalAssign GVExternalLinkage GVVisibilityStyle ThreadLocal OptAddrSpace
|
|
GlobalType Types GlobalVarAttributes
|
|
| OptGlobalAssign GVVisibilityStyle alias AliasLinkage AliaseeRef
|
|
| target TargetDefinition
|
|
| deplibs "=" LibrariesDefinition
|
|
) ^ "\n";
|
|
|
|
AsmBlock ::= STRINGCONSTANT ;
|
|
|
|
TargetDefinition ::= triple "=" STRINGCONSTANT
|
|
| datalayout "=" STRINGCONSTANT ;
|
|
|
|
LibrariesDefinition ::= "[" ( LibList | _ ) "]";
|
|
|
|
LibList ::= LibList ^ "," STRINGCONSTANT | STRINGCONSTANT ;
|
|
|
|
ArgListH ::= ArgListH ^ "," Types OptParamAttrs OptLocalName
|
|
| Types OptParamAttrs OptLocalName ;
|
|
|
|
ArgList ::= ArgListH | ArgListH ^ "," "..." | "..." | _ ;
|
|
|
|
FunctionHeaderH ::= OptCallingConv OptRetAttrs ResultTypes
|
|
GlobalName ^ "(" ^ ArgList ^ ")"
|
|
OptFuncAttrs OptSection OptAlign OptGC ;
|
|
|
|
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 ">"
|
|
| "[" ConstVector "]"
|
|
| "[" ^ "]"
|
|
| "c" ^ STRINGCONSTANT
|
|
| "{" ConstVector "}"
|
|
| "{" ^ "}"
|
|
| "<" ^ "{" ConstVector "}" ^ ">"
|
|
| "<" ^ "{" ^ "}" ^ ">"
|
|
| 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 "]"
|
|
| switch IntType ValueRef ^ "," label ValueRef "[" ^ "]"
|
|
| invoke OptCallingConv ResultTypes ValueRef ^ "(" ^ ParamList ^ ")"
|
|
OptFuncAttrs
|
|
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 ;
|
|
|
|
ConstantIndexList ::= "," EUINT64VAL | ConstantIndexList ^ "," EUINT64VAL ;
|
|
|
|
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
|
|
| "va_arg" ResolvedVal ^ "," Types
|
|
| extractelement ResolvedVal ^ "," ResolvedVal
|
|
| insertelement ResolvedVal ^ "," ResolvedVal ^ "," ResolvedVal
|
|
| shufflevector ResolvedVal ^ "," ResolvedVal ^ "," ResolvedVal
|
|
| phi PHIList
|
|
| OptTailCall OptCallingConv ResultTypes ValueRef ^ "(" ^ ParamList ^ ")"
|
|
OptFuncAttrs
|
|
| MemoryInst ;
|
|
|
|
OptVolatile ::= - volatile | _ ;
|
|
OptExact ::= - exact | _ ;
|
|
OptNSW ::= - nsw | _ ;
|
|
OptNUW ::= - nuw | _ ;
|
|
OptNW ::= OptNUW OptNSW | OptNSW OptNUW ;
|
|
OptInBounds ::= - inbounds | _ ;
|
|
|
|
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
|
|
| getelementptr OptInBounds Types ValueRef IndexList
|
|
| extractvalue Types ValueRef ^ ConstantIndexList
|
|
| insertvalue Types ValueRef ^ "," Types ValueRef ^ ConstantIndexList ;
|