@@ -227,7 +227,7 @@ static Function* makeCtzFunc(MixedArena& allocator, UnaryOp op) {
227227 Builder b (allocator);
228228 // if eqz(x) then 32 else (32 - clz(x ^ (x - 1)))
229229 bool is32Bit = (op == CtzInt32);
230- Name funcName = is32Bit ? Name (CTZ32 ) : Name (CTZ64 );
230+ Name funcName = is32Bit ? Name (WASM_CTZ32 ) : Name (WASM_CTZ64 );
231231 BinaryOp subOp = is32Bit ? SubInt32 : SubInt64;
232232 BinaryOp xorOp = is32Bit ? XorInt32 : XorInt64;
233233 UnaryOp clzOp = is32Bit ? ClzInt32 : ClzInt64;
@@ -270,7 +270,7 @@ static Function* makePopcntFunc(MixedArena& allocator, UnaryOp op) {
270270 // popcnt implemented as:
271271 // int c; for (c = 0; x != 0; c++) { x = x & (x - 1) }; return c
272272 bool is32Bit = (op == PopcntInt32);
273- Name funcName = is32Bit ? Name (POPCNT32 ) : Name (POPCNT64 );
273+ Name funcName = is32Bit ? Name (WASM_POPCNT32 ) : Name (WASM_POPCNT64 );
274274 BinaryOp addOp = is32Bit ? AddInt32 : AddInt64;
275275 BinaryOp subOp = is32Bit ? SubInt32 : SubInt64;
276276 BinaryOp andOp = is32Bit ? AndInt32 : AndInt64;
@@ -328,8 +328,8 @@ Function* makeRotFunc(MixedArena& allocator, BinaryOp op) {
328328 // where k is shift modulo w. reverse shifts for right rotate
329329 bool is32Bit = (op == RotLInt32 || op == RotRInt32);
330330 bool isLRot = (op == RotLInt32 || op == RotLInt64);
331- static Name names[2 ][2 ] = {{Name (ROTR64 ), Name (ROTR32 )},
332- {Name (ROTL64 ), Name (ROTL32 )}};
331+ static Name names[2 ][2 ] = {{Name (WASM_ROTR64 ), Name (WASM_ROTR32 )},
332+ {Name (WASM_ROTL64 ), Name (WASM_ROTL32 )}};
333333 static BinaryOp shifters[2 ][2 ] = {{ShrUInt64, ShrUInt32},
334334 {ShlInt64, ShlInt32}};
335335 Name funcName = names[isLRot][is32Bit];
@@ -1267,15 +1267,26 @@ Ref Wasm2AsmBuilder::processFunctionBody(Function* func, IString result) {
12671267 case i32 : {
12681268 switch (curr->op ) {
12691269 case ClzInt32:
1270- return ValueBuilder::makeCall (MATH_CLZ32,
1271- visit (curr->value ,
1272- EXPRESSION_RESULT));
1270+ return ValueBuilder::makeCall (
1271+ MATH_CLZ32,
1272+ visit (curr->value , EXPRESSION_RESULT)
1273+ );
12731274 case CtzInt32:
1274- return ValueBuilder::makeCall (CTZ32, visit (curr->value ,
1275- EXPRESSION_RESULT));
1275+ return makeSigning (
1276+ ValueBuilder::makeCall (
1277+ WASM_CTZ32,
1278+ visit (curr->value , EXPRESSION_RESULT)
1279+ ),
1280+ ASM_SIGNED
1281+ );
12761282 case PopcntInt32:
1277- return ValueBuilder::makeCall (POPCNT32, visit (curr->value ,
1278- EXPRESSION_RESULT));
1283+ return makeSigning (
1284+ ValueBuilder::makeCall (
1285+ WASM_POPCNT32,
1286+ visit (curr->value , EXPRESSION_RESULT)
1287+ ),
1288+ ASM_SIGNED
1289+ );
12791290 case EqZInt32:
12801291 return ValueBuilder::makeBinary (
12811292 makeAsmCoercion (visit (curr->value ,
@@ -1476,9 +1487,11 @@ Ref Wasm2AsmBuilder::processFunctionBody(Function* func, IString result) {
14761487 return ValueBuilder::makeBinary (makeSigning (left, ASM_UNSIGNED), GE,
14771488 makeSigning (right, ASM_UNSIGNED));
14781489 case RotLInt32:
1479- return ValueBuilder::makeCall (ROTL32, left, right);
1490+ return makeSigning (ValueBuilder::makeCall (WASM_ROTL32, left, right),
1491+ ASM_SIGNED);
14801492 case RotRInt32:
1481- return ValueBuilder::makeCall (ROTR32, left, right);
1493+ return makeSigning (ValueBuilder::makeCall (WASM_ROTR32, left, right),
1494+ ASM_SIGNED);
14821495 default : {
14831496 std::cerr << " Unhandled binary operator: " << curr << std::endl;
14841497 abort ();
0 commit comments