@@ -1917,27 +1917,15 @@ defm SET_f64 : SET<"f64", Float64Regs, f64imm>;
1917
1917
// Data Movement (Load / Store, Move)
1918
1918
//-----------------------------------
1919
1919
1920
- let WantsRoot = true in {
1921
- def ADDRri : ComplexPattern<i32, 2, "SelectADDRri", [frameindex]>;
1922
- def ADDRri64 : ComplexPattern<i64, 2, "SelectADDRri64", [frameindex]>;
1923
- }
1924
- def ADDRvar : ComplexPattern<iPTR, 1, "SelectDirectAddr", [], []>;
1920
+ def addr : ComplexPattern<pAny, 2, "SelectADDR">;
1925
1921
1926
- def MEMri : Operand<i32> {
1927
- let PrintMethod = "printMemOperand";
1928
- let MIOperandInfo = (ops Int32Regs, i32imm);
1929
- }
1930
- def MEMri64 : Operand<i64> {
1931
- let PrintMethod = "printMemOperand";
1932
- let MIOperandInfo = (ops Int64Regs, i64imm);
1933
- }
1934
-
1935
- def imem : Operand<iPTR> {
1922
+ def ADDR_base : Operand<pAny> {
1936
1923
let PrintMethod = "printOperand";
1937
1924
}
1938
1925
1939
- def imemAny : Operand<pAny> {
1940
- let PrintMethod = "printOperand";
1926
+ def ADDR : Operand<pAny> {
1927
+ let PrintMethod = "printMemOperand";
1928
+ let MIOperandInfo = (ops ADDR_base, i32imm);
1941
1929
}
1942
1930
1943
1931
def LdStCode : Operand<i32> {
@@ -1956,10 +1944,10 @@ def SDTWrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
1956
1944
def Wrapper : SDNode<"NVPTXISD::Wrapper", SDTWrapper>;
1957
1945
1958
1946
// Load a memory address into a u32 or u64 register.
1959
- def MOV_ADDR : NVPTXInst<(outs Int32Regs:$dst), (ins imem :$a),
1947
+ def MOV_ADDR : NVPTXInst<(outs Int32Regs:$dst), (ins ADDR_base :$a),
1960
1948
"mov.u32 \t$dst, $a;",
1961
1949
[(set i32:$dst, (Wrapper tglobaladdr:$a))]>;
1962
- def MOV_ADDR64 : NVPTXInst<(outs Int64Regs:$dst), (ins imem :$a),
1950
+ def MOV_ADDR64 : NVPTXInst<(outs Int64Regs:$dst), (ins ADDR_base :$a),
1963
1951
"mov.u64 \t$dst, $a;",
1964
1952
[(set i64:$dst, (Wrapper tglobaladdr:$a))]>;
1965
1953
@@ -2021,12 +2009,17 @@ def : Pat<(i32 (Wrapper texternalsym:$dst)), (IMOV32ri texternalsym:$dst)>;
2021
2009
def : Pat<(i64 (Wrapper texternalsym:$dst)), (IMOV64ri texternalsym:$dst)>;
2022
2010
2023
2011
//---- Copy Frame Index ----
2024
- def LEA_ADDRi : NVPTXInst<(outs Int32Regs:$dst), (ins MEMri:$addr),
2025
- "add.u32 \t$dst, ${addr:add};",
2026
- [(set i32:$dst, ADDRri:$addr)]>;
2027
- def LEA_ADDRi64 : NVPTXInst<(outs Int64Regs:$dst), (ins MEMri64:$addr),
2028
- "add.u64 \t$dst, ${addr:add};",
2029
- [(set i64:$dst, ADDRri64:$addr)]>;
2012
+ def LEA_ADDRi : NVPTXInst<(outs Int32Regs:$dst), (ins ADDR:$addr),
2013
+ "add.u32 \t$dst, ${addr:add};", []>;
2014
+ def LEA_ADDRi64 : NVPTXInst<(outs Int64Regs:$dst), (ins ADDR:$addr),
2015
+ "add.u64 \t$dst, ${addr:add};", []>;
2016
+
2017
+ def to_tframeindex : SDNodeXForm<frameindex, [{
2018
+ return CurDAG->getTargetFrameIndex(N->getIndex(), N->getValueType(0));
2019
+ }]>;
2020
+
2021
+ def : Pat<(i32 frameindex:$fi), (LEA_ADDRi (to_tframeindex $fi), 0)>;
2022
+ def : Pat<(i64 frameindex:$fi), (LEA_ADDRi64 (to_tframeindex $fi), 0)>;
2030
2023
2031
2024
//-----------------------------------
2032
2025
// Comparison and Selection
@@ -2660,7 +2653,7 @@ def CallArgParam : NVPTXInst<(outs), (ins i32imm:$a), "param$a, ",
2660
2653
def LastCallArgParam : NVPTXInst<(outs), (ins i32imm:$a), "param$a",
2661
2654
[(LastCallArg (i32 1), (i32 imm:$a))]>;
2662
2655
2663
- def CallVoidInst : NVPTXInst<(outs), (ins imem :$addr), "$addr, ",
2656
+ def CallVoidInst : NVPTXInst<(outs), (ins ADDR_base :$addr), "$addr, ",
2664
2657
[(CallVoid (Wrapper tglobaladdr:$addr))]>;
2665
2658
def CallVoidInstReg : NVPTXInst<(outs), (ins Int32Regs:$addr), "$addr, ",
2666
2659
[(CallVoid i32:$addr)]>;
@@ -2753,109 +2746,56 @@ foreach vt = [v2f16, v2bf16, v2i16, v4i8] in {
2753
2746
//
2754
2747
// Load / Store Handling
2755
2748
//
2756
- multiclass LD<NVPTXRegClass regclass> {
2757
- def _ari : NVPTXInst<
2749
+ class LD<NVPTXRegClass regclass>
2750
+ : NVPTXInst<
2758
2751
(outs regclass:$dst),
2759
2752
(ins LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec, LdStCode:$Sign,
2760
- i32imm:$fromWidth, Int32Regs:$addr, Offseti32imm:$offset),
2761
- "ld${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2762
- "\t$dst, [$addr$offset];", []>;
2763
- def _ari_64 : NVPTXInst<
2764
- (outs regclass:$dst),
2765
- (ins LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec,
2766
- LdStCode:$Sign, i32imm:$fromWidth, Int64Regs:$addr, Offseti32imm:$offset),
2767
- "ld${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2768
- "\t$dst, [$addr$offset];", []>;
2769
- def _asi : NVPTXInst<
2770
- (outs regclass:$dst),
2771
- (ins LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec,
2772
- LdStCode:$Sign, i32imm:$fromWidth, imem:$addr, Offseti32imm:$offset),
2753
+ i32imm:$fromWidth, ADDR:$addr),
2773
2754
"ld${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2774
- "\t$dst, [$addr$offset];", []>;
2775
- }
2755
+ "\t$dst, [$addr];", []>;
2776
2756
2777
2757
let mayLoad=1, hasSideEffects=0 in {
2778
- defm LD_i8 : LD<Int16Regs>;
2779
- defm LD_i16 : LD<Int16Regs>;
2780
- defm LD_i32 : LD<Int32Regs>;
2781
- defm LD_i64 : LD<Int64Regs>;
2782
- defm LD_f32 : LD<Float32Regs>;
2783
- defm LD_f64 : LD<Float64Regs>;
2758
+ def LD_i8 : LD<Int16Regs>;
2759
+ def LD_i16 : LD<Int16Regs>;
2760
+ def LD_i32 : LD<Int32Regs>;
2761
+ def LD_i64 : LD<Int64Regs>;
2762
+ def LD_f32 : LD<Float32Regs>;
2763
+ def LD_f64 : LD<Float64Regs>;
2784
2764
}
2785
2765
2786
- multiclass ST<NVPTXRegClass regclass> {
2787
- def _ari : NVPTXInst<
2766
+ class ST<NVPTXRegClass regclass>
2767
+ : NVPTXInst<
2788
2768
(outs),
2789
2769
(ins regclass:$src, LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp,
2790
- LdStCode:$Vec, LdStCode:$Sign, i32imm:$toWidth, Int32Regs:$addr,
2791
- Offseti32imm:$offset),
2770
+ LdStCode:$Vec, LdStCode:$Sign, i32imm:$toWidth, ADDR:$addr),
2792
2771
"st${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$toWidth"
2793
- " \t[$addr$offset], $src;", []>;
2794
- def _ari_64 : NVPTXInst<
2795
- (outs),
2796
- (ins regclass:$src, LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp,
2797
- LdStCode:$Vec, LdStCode:$Sign, i32imm:$toWidth, Int64Regs:$addr,
2798
- Offseti32imm:$offset),
2799
- "st${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$toWidth"
2800
- " \t[$addr$offset], $src;", []>;
2801
- def _asi : NVPTXInst<
2802
- (outs),
2803
- (ins regclass:$src, LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp,
2804
- LdStCode:$Vec, LdStCode:$Sign, i32imm:$toWidth, imem:$addr,
2805
- Offseti32imm:$offset),
2806
- "st${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$toWidth"
2807
- " \t[$addr$offset], $src;", []>;
2808
- }
2772
+ " \t[$addr], $src;", []>;
2809
2773
2810
2774
let mayStore=1, hasSideEffects=0 in {
2811
- defm ST_i8 : ST<Int16Regs>;
2812
- defm ST_i16 : ST<Int16Regs>;
2813
- defm ST_i32 : ST<Int32Regs>;
2814
- defm ST_i64 : ST<Int64Regs>;
2815
- defm ST_f32 : ST<Float32Regs>;
2816
- defm ST_f64 : ST<Float64Regs>;
2775
+ def ST_i8 : ST<Int16Regs>;
2776
+ def ST_i16 : ST<Int16Regs>;
2777
+ def ST_i32 : ST<Int32Regs>;
2778
+ def ST_i64 : ST<Int64Regs>;
2779
+ def ST_f32 : ST<Float32Regs>;
2780
+ def ST_f64 : ST<Float64Regs>;
2817
2781
}
2818
2782
2819
2783
// The following is used only in and after vector elementizations. Vector
2820
2784
// elementization happens at the machine instruction level, so the following
2821
2785
// instructions never appear in the DAG.
2822
2786
multiclass LD_VEC<NVPTXRegClass regclass> {
2823
- def _v2_ari : NVPTXInst<
2824
- (outs regclass:$dst1, regclass:$dst2),
2825
- (ins LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec,
2826
- LdStCode:$Sign, i32imm:$fromWidth, Int32Regs:$addr, Offseti32imm:$offset),
2827
- "ld${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2828
- "\t{{$dst1, $dst2}}, [$addr$offset];", []>;
2829
- def _v2_ari_64 : NVPTXInst<
2787
+ def _v2 : NVPTXInst<
2830
2788
(outs regclass:$dst1, regclass:$dst2),
2831
2789
(ins LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec,
2832
- LdStCode:$Sign, i32imm:$fromWidth, Int64Regs :$addr, Offseti32imm:$offset ),
2790
+ LdStCode:$Sign, i32imm:$fromWidth, ADDR :$addr),
2833
2791
"ld${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2834
- "\t{{$dst1, $dst2}}, [$addr$offset];", []>;
2835
- def _v2_asi : NVPTXInst<
2836
- (outs regclass:$dst1, regclass:$dst2),
2837
- (ins LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec,
2838
- LdStCode:$Sign, i32imm:$fromWidth, imem:$addr, Offseti32imm:$offset),
2839
- "ld${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2840
- "\t{{$dst1, $dst2}}, [$addr$offset];", []>;
2841
- def _v4_ari : NVPTXInst<
2792
+ "\t{{$dst1, $dst2}}, [$addr];", []>;
2793
+ def _v4 : NVPTXInst<
2842
2794
(outs regclass:$dst1, regclass:$dst2, regclass:$dst3, regclass:$dst4),
2843
2795
(ins LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec,
2844
- LdStCode:$Sign, i32imm:$fromWidth, Int32Regs :$addr, Offseti32imm:$offset ),
2796
+ LdStCode:$Sign, i32imm:$fromWidth, ADDR :$addr),
2845
2797
"ld${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2846
- "\t{{$dst1, $dst2, $dst3, $dst4}}, [$addr$offset];", []>;
2847
- def _v4_ari_64 : NVPTXInst<
2848
- (outs regclass:$dst1, regclass:$dst2, regclass:$dst3, regclass:$dst4),
2849
- (ins LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec,
2850
- LdStCode:$Sign, i32imm:$fromWidth, Int64Regs:$addr, Offseti32imm:$offset),
2851
- "ld${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2852
- "\t{{$dst1, $dst2, $dst3, $dst4}}, [$addr$offset];", []>;
2853
- def _v4_asi : NVPTXInst<
2854
- (outs regclass:$dst1, regclass:$dst2, regclass:$dst3, regclass:$dst4),
2855
- (ins LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec,
2856
- LdStCode:$Sign, i32imm:$fromWidth, imem:$addr, Offseti32imm:$offset),
2857
- "ld${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2858
- "\t{{$dst1, $dst2, $dst3, $dst4}}, [$addr$offset];", []>;
2798
+ "\t{{$dst1, $dst2, $dst3, $dst4}}, [$addr];", []>;
2859
2799
}
2860
2800
let mayLoad=1, hasSideEffects=0 in {
2861
2801
defm LDV_i8 : LD_VEC<Int16Regs>;
@@ -2867,48 +2807,20 @@ let mayLoad=1, hasSideEffects=0 in {
2867
2807
}
2868
2808
2869
2809
multiclass ST_VEC<NVPTXRegClass regclass> {
2870
- def _v2_ari : NVPTXInst<
2871
- (outs),
2872
- (ins regclass:$src1, regclass:$src2, LdStCode:$sem, LdStCode:$scope,
2873
- LdStCode:$addsp, LdStCode:$Vec, LdStCode:$Sign, i32imm:$fromWidth,
2874
- Int32Regs:$addr, Offseti32imm:$offset),
2875
- "st${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2876
- "\t[$addr$offset], {{$src1, $src2}};", []>;
2877
- def _v2_ari_64 : NVPTXInst<
2810
+ def _v2 : NVPTXInst<
2878
2811
(outs),
2879
2812
(ins regclass:$src1, regclass:$src2, LdStCode:$sem, LdStCode:$scope,
2880
2813
LdStCode:$addsp, LdStCode:$Vec, LdStCode:$Sign, i32imm:$fromWidth,
2881
- Int64Regs:$addr, Offseti32imm:$offset ),
2814
+ ADDR:$addr ),
2882
2815
"st${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2883
- "\t[$addr$offset], {{$src1, $src2}};", []>;
2884
- def _v2_asi : NVPTXInst<
2885
- (outs),
2886
- (ins regclass:$src1, regclass:$src2, LdStCode:$sem, LdStCode:$scope,
2887
- LdStCode:$addsp, LdStCode:$Vec, LdStCode:$Sign, i32imm:$fromWidth,
2888
- imem:$addr, Offseti32imm:$offset),
2889
- "st${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2890
- "\t[$addr$offset], {{$src1, $src2}};", []>;
2891
- def _v4_ari : NVPTXInst<
2816
+ "\t[$addr], {{$src1, $src2}};", []>;
2817
+ def _v4 : NVPTXInst<
2892
2818
(outs),
2893
2819
(ins regclass:$src1, regclass:$src2, regclass:$src3, regclass:$src4,
2894
2820
LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec,
2895
- LdStCode:$Sign, i32imm:$fromWidth, Int32Regs :$addr, Offseti32imm:$offset ),
2821
+ LdStCode:$Sign, i32imm:$fromWidth, ADDR :$addr),
2896
2822
"st${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2897
- "\t[$addr$offset], {{$src1, $src2, $src3, $src4}};", []>;
2898
- def _v4_ari_64 : NVPTXInst<
2899
- (outs),
2900
- (ins regclass:$src1, regclass:$src2, regclass:$src3, regclass:$src4,
2901
- LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec,
2902
- LdStCode:$Sign, i32imm:$fromWidth, Int64Regs:$addr, Offseti32imm:$offset),
2903
- "st${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}$fromWidth "
2904
- "\t[$addr$offset], {{$src1, $src2, $src3, $src4}};", []>;
2905
- def _v4_asi : NVPTXInst<
2906
- (outs),
2907
- (ins regclass:$src1, regclass:$src2, regclass:$src3, regclass:$src4,
2908
- LdStCode:$sem, LdStCode:$scope, LdStCode:$addsp, LdStCode:$Vec,
2909
- LdStCode:$Sign, i32imm:$fromWidth, imem:$addr, Offseti32imm:$offset),
2910
- "st${sem:sem}${scope:scope}${addsp:addsp}${Vec:vec}.${Sign:sign}"
2911
- "$fromWidth \t[$addr$offset], {{$src1, $src2, $src3, $src4}};", []>;
2823
+ "\t[$addr], {{$src1, $src2, $src3, $src4}};", []>;
2912
2824
}
2913
2825
2914
2826
let mayStore=1, hasSideEffects=0 in {
0 commit comments