@@ -906,8 +906,22 @@ SelectionKind -> SelectionKind
906
906
# Const OptionalAttrs
907
907
908
908
GlobalDecl -> GlobalDecl
909
- : Name=GlobalIdent '=' Linkage=ExternLinkage Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt AddrSpaceopt ExternallyInitializedopt Immutable ContentType=Type (',' Section)? (',' Partition)? (',' Comdat)? (',' Align)? Metadata=(',' MetadataAttachment)+? FuncAttrs=FuncAttribute+?
910
- | Name=GlobalIdent '=' Linkage=Linkageopt Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt AddrSpaceopt ExternallyInitializedopt Immutable ContentType=Type Init=Constant (',' Section)? (',' Partition)? (',' Comdat)? (',' Align)? Metadata=(',' MetadataAttachment)+? FuncAttrs=FuncAttribute+?
909
+ #: Name=GlobalIdent '=' Linkage=ExternLinkage Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt AddrSpaceopt ExternallyInitializedopt Immutable ContentType=Type (',' Section)? (',' Partition)? (',' Comdat)? (',' Align)? Metadata=(',' MetadataAttachment)+? FuncAttrs=FuncAttribute+?
910
+ #| Name=GlobalIdent '=' Linkage=Linkageopt Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt AddrSpaceopt ExternallyInitializedopt Immutable ContentType=Type Init=Constant (',' Section)? (',' Partition)? (',' Comdat)? (',' Align)? Metadata=(',' MetadataAttachment)+? FuncAttrs=FuncAttribute+?
911
+ : Name=GlobalIdent '=' Linkage=ExternLinkage Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt AddrSpaceopt ExternallyInitializedopt Immutable ContentType=Type GlobalFields=(',' GlobalField)* Metadata=(',' MetadataAttachment)+? FuncAttrs=FuncAttribute+?
912
+ | Name=GlobalIdent '=' Linkage=Linkageopt Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt AddrSpaceopt ExternallyInitializedopt Immutable ContentType=Type Init=Constant GlobalFields=(',' GlobalField)* Metadata=(',' MetadataAttachment)+? FuncAttrs=FuncAttribute+?
913
+ ;
914
+
915
+ # NOTE: GlobalField is a workaround to handle the LR-1 shift/reduce conflict
916
+ # between FuncAttribute and Align, both of which contain 'align'.
917
+
918
+ %interface GlobalField;
919
+
920
+ GlobalField -> GlobalField
921
+ : Section
922
+ | Partition
923
+ | Comdat
924
+ | Align
911
925
;
912
926
913
927
ExternallyInitialized -> ExternallyInitialized
@@ -996,11 +1010,26 @@ FuncDef -> FuncDef
996
1010
# '(' ArgList ')' OptAddrSpace OptFuncAttrs OptSection OptPartition
997
1011
# OptionalAlign OptGC OptionalPrefix OptionalPrologue OptPersonalityFn
998
1012
999
- # TODO: Add Alignopt before GCopt once the LR-1 conflict has been resolved.
1000
- # The shift/reduce conflict is present since FuncAttribute also contains 'align'.
1001
-
1002
1013
FuncHeader -> FuncHeader
1003
- : (Linkage | ExternLinkage)? Preemptionopt Visibilityopt DLLStorageClassopt CallingConvopt ReturnAttrs=ReturnAttribute* RetType=Type Name=GlobalIdent '(' Params ')' UnnamedAddropt AddrSpaceopt FuncAttrs=FuncAttributeAndAlign* Sectionopt Partitionopt Comdatopt GCopt Prefixopt Prologueopt Personalityopt
1014
+ #: (Linkage | ExternLinkage)? Preemptionopt Visibilityopt DLLStorageClassopt CallingConvopt ReturnAttrs=ReturnAttribute* RetType=Type Name=GlobalIdent '(' Params ')' UnnamedAddropt AddrSpaceopt FuncAttrs=FuncAttributeAndAlign* Sectionopt Partitionopt Comdatopt Alignopt GCopt Prefixopt Prologueopt Personalityopt
1015
+ : (Linkage | ExternLinkage)? Preemptionopt Visibilityopt DLLStorageClassopt CallingConvopt ReturnAttrs=ReturnAttribute* RetType=Type Name=GlobalIdent '(' Params ')' UnnamedAddropt AddrSpaceopt FuncHdrFields=FuncHdrField*
1016
+ ;
1017
+
1018
+ # NOTE: FuncHdrField is a workaround to handle the LR-1 shift/reduce conflict
1019
+ # between FuncAttribute and Align, both of which contain 'align'.
1020
+
1021
+ %interface FuncHdrField;
1022
+
1023
+ FuncHdrField -> FuncHdrField
1024
+ : FuncAttribute
1025
+ | Section
1026
+ | Partition
1027
+ | Comdat
1028
+ | Align
1029
+ | GC
1030
+ | Prefix
1031
+ | Prologue
1032
+ | Personality
1004
1033
;
1005
1034
1006
1035
# NOTE: Named GCNode instead of GC to avoid collisions with 'gc' token. Both
@@ -2657,6 +2686,8 @@ SelectInst -> SelectInst
2657
2686
#
2658
2687
# bundle-tag ::= String Constant
2659
2688
2689
+ # TODO: add align as valid function attribute to CallInst.
2690
+
2660
2691
CallInst -> CallInst
2661
2692
: Tailopt 'call' FastMathFlags=FastMathFlag* CallingConvopt ReturnAttrs=ReturnAttribute* AddrSpaceopt Typ=Type Callee=Value '(' Args ')' FuncAttrs=FuncAttribute* OperandBundles=('[ ' (OperandBundle separator ',')+ '] ')? Metadata=(',' MetadataAttachment)+?
2662
2693
;
@@ -2794,7 +2825,9 @@ BrTerm -> BrTerm
2794
2825
;
2795
2826
2796
2827
# TODO: replace `IntType Value` with TypeValue when the parser generator
2797
- # is capable of handling the shift/reduce conflict.
2828
+ # is capable of handling the shift/reduce conflict. When TypeValue is used, the
2829
+ # conflict happens as 'br' 'label' may be the start of either BrTerm or
2830
+ # CondBrTerm.
2798
2831
2799
2832
# Conditional branch.
2800
2833
CondBrTerm -> CondBrTerm
@@ -2840,6 +2873,8 @@ IndirectBrTerm -> IndirectBrTerm
2840
2873
# ::= 'invoke' OptionalCallingConv OptionalAttrs Type Value ParamList
2841
2874
# OptionalAttrs 'to' TypeAndValue 'unwind' TypeAndValue
2842
2875
2876
+ # TODO: add align as valid function attribute to InvokeTerm.
2877
+
2843
2878
InvokeTerm -> InvokeTerm
2844
2879
: 'invoke' CallingConvopt ReturnAttrs=ReturnAttribute* AddrSpaceopt Typ=Type Invokee=Value '(' Args ')' FuncAttrs=FuncAttribute* OperandBundles=('[ ' (OperandBundle separator ',')+ '] ')? 'to' Normal=Label 'unwind' Exception=Label Metadata=(',' MetadataAttachment)+?
2845
2880
;
@@ -3348,7 +3383,7 @@ DIGlobalVariableField -> DIGlobalVariableField
3348
3383
3349
3384
# ~~~ [ DIGlobalVariableExpression ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3350
3385
3351
- # TODO: add link to LangRef.html.
3386
+ # https://llvm.org/docs/ LangRef.html#diglobalvariableexpression
3352
3387
3353
3388
# ref: ParseDIGlobalVariableExpression
3354
3389
#
@@ -4636,16 +4671,10 @@ FPred -> FPred
4636
4671
# ::= <attr> | <attr> '=' <value>
4637
4672
4638
4673
# NOTE: FuncAttribute should contain Align. However, using LALR(1) this
4639
- # produces a reduce/reduce conflict as GlobalAttr also contains Align.
4640
- #
4641
- # To handle these ambiguities, (FuncAttribute | Align) is used in those places
4642
- # where FuncAttribute is used outside of GlobalDef and GlobalDecl (which also has
4643
- # GlobalAttr).
4674
+ # produces a reduce/reduce conflict as GlobalDecl also contains Align.
4644
4675
4645
4676
%interface FuncAttribute;
4646
4677
4647
- # TODO: Figure out how to enable Align in FuncAttribute again.
4648
-
4649
4678
FuncAttribute -> FuncAttribute
4650
4679
: AttrString
4651
4680
| AttrPair
@@ -4661,13 +4690,6 @@ FuncAttribute -> FuncAttribute
4661
4690
| FuncAttr
4662
4691
;
4663
4692
4664
- %interface FuncAttributeAndAlign;
4665
-
4666
- FuncAttributeAndAlign -> FuncAttributeAndAlign
4667
- : FuncAttribute
4668
- | Align
4669
- ;
4670
-
4671
4693
FuncAttr -> FuncAttr
4672
4694
: 'alwaysinline'
4673
4695
| 'argmemonly'
@@ -4760,12 +4782,6 @@ Label -> Label
4760
4782
# this is not possible as it leads to shift/reduce conflicts (when merging
4761
4783
# GlobalDecl and GlobalDef). Perhaps when the parser generator is better capable
4762
4784
# at resolving conflicts.
4763
- #
4764
- # ll.tm,812: input: TopLevelEntity_optlist GlobalIdent '=' Linkageopt Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt AddrSpaceopt ExternallyInitializedopt Immutable Type
4765
- # shift/reduce conflict (next: global_ident_tok)
4766
- # GlobalDecl : GlobalIdent '=' Linkageopt Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt AddrSpaceopt ExternallyInitializedopt Immutable Type
4767
- #
4768
- # conflicts: 1 shift/reduce and 0 reduce/reduce
4769
4785
4770
4786
Linkage -> Linkage
4771
4787
: 'appending'
@@ -4870,7 +4886,7 @@ ReturnAttribute -> ReturnAttribute
4870
4886
# - `ReturnAttrs` cannot be nullable, since it precedes FuncAttrs
4871
4887
#: AttrString
4872
4888
#| AttrPair
4873
- #: Align
4889
+ #| Align
4874
4890
: Dereferenceable
4875
4891
| ReturnAttr
4876
4892
;
0 commit comments