Skip to content

Commit d0bf981

Browse files
author
Dan Gohman
committed
[WebAssembly] Rename several functions and types according to the new spec.
llvm-svn: 248644
1 parent 6993ba4 commit d0bf981

14 files changed

+192
-192
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
107107
setStackPointerRegisterToSaveRestore(
108108
Subtarget->hasAddr64() ? WebAssembly::SP64 : WebAssembly::SP32);
109109
// Set up the register classes.
110-
addRegisterClass(MVT::i32, &WebAssembly::Int32RegClass);
111-
addRegisterClass(MVT::i64, &WebAssembly::Int64RegClass);
112-
addRegisterClass(MVT::f32, &WebAssembly::Float32RegClass);
113-
addRegisterClass(MVT::f64, &WebAssembly::Float64RegClass);
110+
addRegisterClass(MVT::i32, &WebAssembly::I32RegClass);
111+
addRegisterClass(MVT::i64, &WebAssembly::I64RegClass);
112+
addRegisterClass(MVT::f32, &WebAssembly::F32RegClass);
113+
addRegisterClass(MVT::f64, &WebAssembly::F64RegClass);
114114
// Compute derived properties from the register classes.
115115
computeRegisterProperties(Subtarget->getRegisterInfo());
116116

llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ def : I<(outs), (ins i64imm:$amt1, i64imm:$amt2),
2222
} // isCodeGenOnly = 1
2323

2424
multiclass CALL<WebAssemblyRegClass vt> {
25-
def CALL_#vt : I<(outs vt:$dst), (ins Int32:$callee, variable_ops),
26-
[(set vt:$dst, (WebAssemblycall1 Int32:$callee))]>;
25+
def CALL_#vt : I<(outs vt:$dst), (ins I32:$callee, variable_ops),
26+
[(set vt:$dst, (WebAssemblycall1 I32:$callee))]>;
2727
}
2828
let Uses = [SP32, SP64], isCall = 1 in {
29-
defm : CALL<Int32>;
30-
defm : CALL<Int64>;
31-
defm : CALL<Float32>;
32-
defm : CALL<Float64>;
29+
defm : CALL<I32>;
30+
defm : CALL<I64>;
31+
defm : CALL<F32>;
32+
defm : CALL<F64>;
3333

34-
def CALL_VOID : I<(outs), (ins Int32:$callee, variable_ops),
35-
[(WebAssemblycall0 Int32:$callee)]>;
34+
def CALL_VOID : I<(outs), (ins I32:$callee, variable_ops),
35+
[(WebAssemblycall0 I32:$callee)]>;
3636
} // Uses = [SP32,SP64], isCall = 1
3737

3838
/*
3939
* TODO(jfb): Add the following.
4040
*
41-
* call_direct: call function directly
41+
* call: call function directly
4242
* call_indirect: call function indirectly
4343
* addressof: obtain a function pointer value for a given function
4444
*/

llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td

+10-10
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
*/
2727

2828
let isBranch = 1, isTerminator = 1, hasCtrlDep = 1 in {
29-
def BRIF : I<(outs), (ins bb_op:$dst, Int32:$a),
30-
[(brcond Int32:$a, bb:$dst)]>;
29+
def BRIF : I<(outs), (ins bb_op:$dst, I32:$a),
30+
[(brcond I32:$a, bb:$dst)]>;
3131
let isBarrier = 1 in {
3232
def BR : I<(outs), (ins bb_op:$dst),
3333
[(br bb:$dst)]>;
@@ -38,10 +38,10 @@ def BR : I<(outs), (ins bb_op:$dst),
3838
// jump tables, so in practice we don't ever use SWITCH_I64 in wasm32 mode
3939
// currently.
4040
let isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
41-
def SWITCH_I32 : I<(outs), (ins Int32:$index, variable_ops),
42-
[(WebAssemblyswitch Int32:$index)]>;
43-
def SWITCH_I64 : I<(outs), (ins Int64:$index, variable_ops),
44-
[(WebAssemblyswitch Int64:$index)]>;
41+
def SWITCH_I32 : I<(outs), (ins I32:$index, variable_ops),
42+
[(WebAssemblyswitch I32:$index)]>;
43+
def SWITCH_I64 : I<(outs), (ins I64:$index, variable_ops),
44+
[(WebAssemblyswitch I64:$index)]>;
4545
} // isTerminator = 1, hasCtrlDep = 1, isBarrier = 1
4646

4747
// Placemarkers to indicate the start of a block or loop scope.
@@ -52,9 +52,9 @@ multiclass RETURN<WebAssemblyRegClass vt> {
5252
def RETURN_#vt : I<(outs), (ins vt:$val), [(WebAssemblyreturn vt:$val)]>;
5353
}
5454
let isReturn = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
55-
defm : RETURN<Int32>;
56-
defm : RETURN<Int64>;
57-
defm : RETURN<Float32>;
58-
defm : RETURN<Float64>;
55+
defm : RETURN<I32>;
56+
defm : RETURN<I64>;
57+
defm : RETURN<F32>;
58+
defm : RETURN<F64>;
5959
def RETURN_VOID : I<(outs), (ins), [(WebAssemblyreturn)]>;
6060
} // isReturn = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1

llvm/lib/Target/WebAssembly/WebAssemblyInstrConv.td

+27-27
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,32 @@
1616
/*
1717
* TODO(jfb): Add the following.
1818
*
19-
* int32.wrap[int64]: wrap a 64-bit integer to a 32-bit integer
20-
* int32.trunc_signed[float32]: truncate a 32-bit float to a signed 32-bit integer
21-
* int32.trunc_signed[float64]: truncate a 64-bit float to a signed 32-bit integer
22-
* int32.trunc_unsigned[float32]: truncate a 32-bit float to an unsigned 32-bit integer
23-
* int32.trunc_unsigned[float64]: truncate a 64-bit float to an unsigned 32-bit integer
24-
* int32.reinterpret[float32]: reinterpret the bits of a 32-bit float as a 32-bit integer
25-
* int64.extend_signed[int32]: extend a signed 32-bit integer to a 64-bit integer
26-
* int64.extend_unsigned[int32]: extend an unsigned 32-bit integer to a 64-bit integer
27-
* int64.trunc_signed[float32]: truncate a 32-bit float to a signed 64-bit integer
28-
* int64.trunc_signed[float64]: truncate a 64-bit float to a signed 64-bit integer
29-
* int64.trunc_unsigned[float32]: truncate a 32-bit float to an unsigned 64-bit integer
30-
* int64.trunc_unsigned[float64]: truncate a 64-bit float to an unsigned 64-bit integer
31-
* int64.reinterpret[float64]: reinterpret the bits of a 64-bit float as a 64-bit integer
32-
* float32.demote[float64]: demote a 64-bit float to a 32-bit float
33-
* float32.cvt_signed[int32]: convert a signed 32-bit integer to a 32-bit float
34-
* float32.cvt_signed[int64]: convert a signed 64-bit integer to a 32-bit float
35-
* float32.cvt_unsigned[int32]: convert an unsigned 32-bit integer to a 32-bit float
36-
* float32.cvt_unsigned[int64]: convert an unsigned 64-bit integer to a 32-bit float
37-
* float32.reinterpret[int32]: reinterpret the bits of a 32-bit integer as a 32-bit float
38-
* float64.promote[float32]: promote a 32-bit float to a 64-bit float
39-
* float64.cvt_signed[int32]: convert a signed 32-bit integer to a 64-bit float
40-
* float64.cvt_signed[int64]: convert a signed 64-bit integer to a 64-bit float
41-
* float64.cvt_unsigned[int32]: convert an unsigned 32-bit integer to a 64-bit float
42-
* float64.cvt_unsigned[int64]: convert an unsigned 64-bit integer to a 64-bit float
43-
* float64.reinterpret[int64]: reinterpret the bits of a 64-bit integer as a 64-bit float
19+
* i32.wrap[i64]: wrap a 64-bit integer to a 32-bit integer
20+
* i32.trunc_s[f32]: truncate a 32-bit float to a signed 32-bit integer
21+
* i32.trunc_s[f64]: truncate a 64-bit float to a signed 32-bit integer
22+
* i32.trunc_u[f32]: truncate a 32-bit float to an unsigned 32-bit integer
23+
* i32.trunc_u[f64]: truncate a 64-bit float to an unsigned 32-bit integer
24+
* i32.reinterpret[f32]: reinterpret the bits of a 32-bit float as a 32-bit integer
25+
* i64.extend_s[i32]: extend a signed 32-bit integer to a 64-bit integer
26+
* i64.extend_u[i32]: extend an unsigned 32-bit integer to a 64-bit integer
27+
* i64.trunc_s[f32]: truncate a 32-bit float to a signed 64-bit integer
28+
* i64.trunc_s[f64]: truncate a 64-bit float to a signed 64-bit integer
29+
* i64.trunc_u[f32]: truncate a 32-bit float to an unsigned 64-bit integer
30+
* i64.trunc_u[f64]: truncate a 64-bit float to an unsigned 64-bit integer
31+
* i64.reinterpret[f64]: reinterpret the bits of a 64-bit float as a 64-bit integer
32+
* f32.demote[f64]: demote a 64-bit float to a 32-bit float
33+
* f32.convert_s[i32]: convert a signed 32-bit integer to a 32-bit float
34+
* f32.convert_s[i64]: convert a signed 64-bit integer to a 32-bit float
35+
* f32.convert_u[i32]: convert an unsigned 32-bit integer to a 32-bit float
36+
* f32.convert_u[i64]: convert an unsigned 64-bit integer to a 32-bit float
37+
* f32.reinterpret[i32]: reinterpret the bits of a 32-bit integer as a 32-bit float
38+
* f64.promote[f32]: promote a 32-bit float to a 64-bit float
39+
* f64.convert_s[i32]: convert a signed 32-bit integer to a 64-bit float
40+
* f64.convert_s[i64]: convert a signed 64-bit integer to a 64-bit float
41+
* f64.convert_u[i32]: convert an unsigned 32-bit integer to a 64-bit float
42+
* f64.convert_u[i64]: convert an unsigned 64-bit integer to a 64-bit float
43+
* f64.reinterpret[i64]: reinterpret the bits of a 64-bit integer as a 64-bit float
4444
*/
4545

46-
def WRAP_I64_I32 : I<(outs Int32:$dst), (ins Int64:$src),
47-
[(set Int32:$dst, (trunc Int64:$src))]>;
46+
def WRAP_I64_I32 : I<(outs I32:$dst), (ins I64:$src),
47+
[(set I32:$dst, (trunc I64:$src))]>;

llvm/lib/Target/WebAssembly/WebAssemblyInstrFloat.td

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ defm COPYSIGN : BinaryFP<fcopysign>;
2525
defm CEIL : UnaryFP<fceil>;
2626
defm FLOOR : UnaryFP<ffloor>;
2727
defm TRUNC : UnaryFP<ftrunc>;
28-
defm NEARESTINT : UnaryFP<fnearbyint>;
28+
defm NEAREST : UnaryFP<fnearbyint>;
2929

3030
// WebAssembly doesn't expose inexact exceptions, so map frint to fnearbyint.
31-
def : Pat<(frint f32:$src), (NEARESTINT_F32 f32:$src)>;
32-
def : Pat<(frint f64:$src), (NEARESTINT_F64 f64:$src)>;
31+
def : Pat<(frint f32:$src), (NEAREST_F32 f32:$src)>;
32+
def : Pat<(frint f64:$src), (NEAREST_F64 f64:$src)>;
3333

3434
defm EQ : ComparisonFP<SETOEQ>;
3535
defm NE : ComparisonFP<SETUNE>;
@@ -55,6 +55,6 @@ def : Pat<(setge f64:$lhs, f64:$rhs), (GE_F64 f64:$lhs, f64:$rhs)>;
5555
/*
5656
* TODO(jfb): Add the following for 32-bit and 64-bit.
5757
*
58-
* float32.min: minimum (binary operator); if either operand is NaN, returns NaN
59-
* float32.max: maximum (binary operator); if either operand is NaN, returns NaN
58+
* f32.min: minimum (binary operator); if either operand is NaN, returns NaN
59+
* f32.max: maximum (binary operator); if either operand is NaN, returns NaN
6060
*/

llvm/lib/Target/WebAssembly/WebAssemblyInstrFormats.td

+24-24
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,38 @@ class I<dag oops, dag iops, list<dag> pattern, string cstr = "">
3030

3131
// Unary and binary instructions, for the local types that WebAssembly supports.
3232
multiclass UnaryInt<SDNode node> {
33-
def _I32 : I<(outs Int32:$dst), (ins Int32:$src),
34-
[(set Int32:$dst, (node Int32:$src))]>;
35-
def _I64 : I<(outs Int64:$dst), (ins Int64:$src),
36-
[(set Int64:$dst, (node Int64:$src))]>;
33+
def _I32 : I<(outs I32:$dst), (ins I32:$src),
34+
[(set I32:$dst, (node I32:$src))]>;
35+
def _I64 : I<(outs I64:$dst), (ins I64:$src),
36+
[(set I64:$dst, (node I64:$src))]>;
3737
}
3838
multiclass BinaryInt<SDNode node> {
39-
def _I32 : I<(outs Int32:$dst), (ins Int32:$lhs, Int32:$rhs),
40-
[(set Int32:$dst, (node Int32:$lhs, Int32:$rhs))]>;
41-
def _I64 : I<(outs Int64:$dst), (ins Int64:$lhs, Int64:$rhs),
42-
[(set Int64:$dst, (node Int64:$lhs, Int64:$rhs))]>;
39+
def _I32 : I<(outs I32:$dst), (ins I32:$lhs, I32:$rhs),
40+
[(set I32:$dst, (node I32:$lhs, I32:$rhs))]>;
41+
def _I64 : I<(outs I64:$dst), (ins I64:$lhs, I64:$rhs),
42+
[(set I64:$dst, (node I64:$lhs, I64:$rhs))]>;
4343
}
4444
multiclass UnaryFP<SDNode node> {
45-
def _F32 : I<(outs Float32:$dst), (ins Float32:$src),
46-
[(set Float32:$dst, (node Float32:$src))]>;
47-
def _F64 : I<(outs Float64:$dst), (ins Float64:$src),
48-
[(set Float64:$dst, (node Float64:$src))]>;
45+
def _F32 : I<(outs F32:$dst), (ins F32:$src),
46+
[(set F32:$dst, (node F32:$src))]>;
47+
def _F64 : I<(outs F64:$dst), (ins F64:$src),
48+
[(set F64:$dst, (node F64:$src))]>;
4949
}
5050
multiclass BinaryFP<SDNode node> {
51-
def _F32 : I<(outs Float32:$dst), (ins Float32:$lhs, Float32:$rhs),
52-
[(set Float32:$dst, (node Float32:$lhs, Float32:$rhs))]>;
53-
def _F64 : I<(outs Float64:$dst), (ins Float64:$lhs, Float64:$rhs),
54-
[(set Float64:$dst, (node Float64:$lhs, Float64:$rhs))]>;
51+
def _F32 : I<(outs F32:$dst), (ins F32:$lhs, F32:$rhs),
52+
[(set F32:$dst, (node F32:$lhs, F32:$rhs))]>;
53+
def _F64 : I<(outs F64:$dst), (ins F64:$lhs, F64:$rhs),
54+
[(set F64:$dst, (node F64:$lhs, F64:$rhs))]>;
5555
}
5656
multiclass ComparisonInt<CondCode cond> {
57-
def _I32 : I<(outs Int32:$dst), (ins Int32:$lhs, Int32:$rhs),
58-
[(set Int32:$dst, (setcc Int32:$lhs, Int32:$rhs, cond))]>;
59-
def _I64 : I<(outs Int32:$dst), (ins Int64:$lhs, Int64:$rhs),
60-
[(set Int32:$dst, (setcc Int64:$lhs, Int64:$rhs, cond))]>;
57+
def _I32 : I<(outs I32:$dst), (ins I32:$lhs, I32:$rhs),
58+
[(set I32:$dst, (setcc I32:$lhs, I32:$rhs, cond))]>;
59+
def _I64 : I<(outs I32:$dst), (ins I64:$lhs, I64:$rhs),
60+
[(set I32:$dst, (setcc I64:$lhs, I64:$rhs, cond))]>;
6161
}
6262
multiclass ComparisonFP<CondCode cond> {
63-
def _F32 : I<(outs Int32:$dst), (ins Float32:$lhs, Float32:$rhs),
64-
[(set Int32:$dst, (setcc Float32:$lhs, Float32:$rhs, cond))]>;
65-
def _F64 : I<(outs Int32:$dst), (ins Float64:$lhs, Float64:$rhs),
66-
[(set Int32:$dst, (setcc Float64:$lhs, Float64:$rhs, cond))]>;
63+
def _F32 : I<(outs I32:$dst), (ins F32:$lhs, F32:$rhs),
64+
[(set I32:$dst, (setcc F32:$lhs, F32:$rhs, cond))]>;
65+
def _F64 : I<(outs I32:$dst), (ins F64:$lhs, F64:$rhs),
66+
[(set I32:$dst, (setcc F64:$lhs, F64:$rhs, cond))]>;
6767
}

llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td

+16-16
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,26 @@ multiclass ARGUMENT<WebAssemblyRegClass vt> {
8787
def ARGUMENT_#vt : I<(outs vt:$res), (ins i32imm:$argno),
8888
[(set vt:$res, (WebAssemblyargument timm:$argno))]>;
8989
}
90-
defm : ARGUMENT<Int32>;
91-
defm : ARGUMENT<Int64>;
92-
defm : ARGUMENT<Float32>;
93-
defm : ARGUMENT<Float64>;
90+
defm : ARGUMENT<I32>;
91+
defm : ARGUMENT<I64>;
92+
defm : ARGUMENT<F32>;
93+
defm : ARGUMENT<F64>;
9494

9595

96-
def Immediate_I32 : I<(outs Int32:$res), (ins i32imm:$imm),
97-
[(set Int32:$res, imm:$imm)]>;
98-
def Immediate_I64 : I<(outs Int64:$res), (ins i64imm:$imm),
99-
[(set Int64:$res, imm:$imm)]>;
100-
def Immediate_F32 : I<(outs Float32:$res), (ins f32imm:$imm),
101-
[(set Float32:$res, fpimm:$imm)]>;
102-
def Immediate_F64 : I<(outs Float64:$res), (ins f64imm:$imm),
103-
[(set Float64:$res, fpimm:$imm)]>;
96+
def Immediate_I32 : I<(outs I32:$res), (ins i32imm:$imm),
97+
[(set I32:$res, imm:$imm)]>;
98+
def Immediate_I64 : I<(outs I64:$res), (ins i64imm:$imm),
99+
[(set I64:$res, imm:$imm)]>;
100+
def Immediate_F32 : I<(outs F32:$res), (ins f32imm:$imm),
101+
[(set F32:$res, fpimm:$imm)]>;
102+
def Immediate_F64 : I<(outs F64:$res), (ins f64imm:$imm),
103+
[(set F64:$res, fpimm:$imm)]>;
104104

105105
// Special types of immediates. FIXME: Hard-coded as 32-bit for now.
106-
def GLOBAL : I<(outs Int32:$dst), (ins global:$addr),
107-
[(set Int32:$dst, (WebAssemblywrapper tglobaladdr:$addr))]>;
108-
def JUMP_TABLE : I<(outs Int32:$dst), (ins tjumptable_op:$addr),
109-
[(set Int32:$dst, (WebAssemblywrapper tjumptable:$addr))]>;
106+
def GLOBAL : I<(outs I32:$dst), (ins global:$addr),
107+
[(set I32:$dst, (WebAssemblywrapper tglobaladdr:$addr))]>;
108+
def JUMP_TABLE : I<(outs I32:$dst), (ins tjumptable_op:$addr),
109+
[(set I32:$dst, (WebAssemblywrapper tjumptable:$addr))]>;
110110

111111
//===----------------------------------------------------------------------===//
112112
// Additional sets of instructions.

llvm/lib/Target/WebAssembly/WebAssemblyInstrInteger.td

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ defm CTZ : UnaryInt<cttz>;
4242
defm POPCNT : UnaryInt<ctpop>;
4343

4444
// Expand the "don't care" operations to supported operations.
45-
def : Pat<(ctlz_zero_undef Int32:$src), (CLZ_I32 Int32:$src)>;
46-
def : Pat<(ctlz_zero_undef Int64:$src), (CLZ_I64 Int64:$src)>;
47-
def : Pat<(cttz_zero_undef Int32:$src), (CTZ_I32 Int32:$src)>;
48-
def : Pat<(cttz_zero_undef Int64:$src), (CTZ_I64 Int64:$src)>;
45+
def : Pat<(ctlz_zero_undef I32:$src), (CLZ_I32 I32:$src)>;
46+
def : Pat<(ctlz_zero_undef I64:$src), (CLZ_I64 I64:$src)>;
47+
def : Pat<(cttz_zero_undef I32:$src), (CTZ_I32 I32:$src)>;
48+
def : Pat<(cttz_zero_undef I64:$src), (CTZ_I64 I64:$src)>;

0 commit comments

Comments
 (0)