Skip to content

Commit c15dacc

Browse files
kddnewtonmeta-codesync[bot]
authored andcommitted
Move x64 sign extension opcodes out of general
Summary: These three sign-extension opcodes are specific to x86-64 and are entirely skipped in aarch64. They're a good candidate as the first set of things to be target-specific. This diff makes them only visible on x86-64, changes their name to be target-specific, and gets to not worry about them on aarch64. Reviewed By: DinoV Differential Revision: D107693080 fbshipit-source-id: 0405e8a4cb7f9bea30b3e13c9d313b6b0868976f
1 parent 4b5f23d commit c15dacc

4 files changed

Lines changed: 23 additions & 22 deletions

File tree

cinderx/Jit/codegen/autogen.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,21 +2567,21 @@ void AutoTranslator::translateInstr(Environ* env, const Instruction* instr)
25672567
}
25682568
return;
25692569
}
2570-
case Instruction::kCdq: {
2570+
case Instruction::kX64Cdq: {
25712571
auto* output = instr->output();
25722572
auto* input = instr->getInput(0);
25732573

25742574
env->as->cdq(getReg(instr, output), getReg(instr, input));
25752575
return;
25762576
}
2577-
case Instruction::kCwd: {
2577+
case Instruction::kX64Cwd: {
25782578
auto* output = instr->output();
25792579
auto* input = instr->getInput(0);
25802580

25812581
env->as->cwd(getReg(instr, output), getReg(instr, input));
25822582
return;
25832583
}
2584-
case Instruction::kCqo: {
2584+
case Instruction::kX64Cqo: {
25852585
auto* output = instr->output();
25862586
auto* input = instr->getInput(0);
25872587

@@ -3337,9 +3337,6 @@ void AutoTranslator::translateInstr(Environ* env, const Instruction* instr)
33373337
case Instruction::kVarArgCall:
33383338
case Instruction::kSext:
33393339
case Instruction::kZext:
3340-
case Instruction::kCdq:
3341-
case Instruction::kCwd:
3342-
case Instruction::kCqo:
33433340
case Instruction::kLoadArg:
33443341
case Instruction::kLoadSecondCallResult:
33453342
case Instruction::kCondBranch:

cinderx/Jit/lir/instruction.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ enum OperandSizeType {
106106
X(MovConstPool, false, FlagEffects::kNone, kOut) \
107107
X(Push, false, FlagEffects::kNone, kDefault, 1, {}, 1) \
108108
X(Pop, false, FlagEffects::kNone, kDefault, 0, {}, 1) \
109-
X(Cdq, false, FlagEffects::kNone, kDefault, 1, {}, 1) \
110-
X(Cwd, false, FlagEffects::kNone, kDefault, 1, {}, 1) \
111-
X(Cqo, false, FlagEffects::kNone, kDefault, 1, {}, 1) \
112109
X(Branch) \
113110
X(BranchNZ) \
114111
X(BranchZ) \
@@ -196,7 +193,11 @@ enum OperandSizeType {
196193
* do?).
197194
*/
198195
#if defined(CINDER_X86_64)
199-
#define FOREACH_INSTR_TYPE(X) FOREACH_COMMON_INSTR_TYPE(X)
196+
#define FOREACH_INSTR_TYPE(X) \
197+
FOREACH_COMMON_INSTR_TYPE(X) \
198+
X(X64Cdq, false, FlagEffects::kNone, kDefault, 1, {}, 1) \
199+
X(X64Cwd, false, FlagEffects::kNone, kDefault, 1, {}, 1) \
200+
X(X64Cqo, false, FlagEffects::kNone, kDefault, 1, {}, 1)
200201
#elif defined(CINDER_AARCH64)
201202
#define FOREACH_INSTR_TYPE(X) FOREACH_COMMON_INSTR_TYPE(X)
202203
#else

cinderx/Jit/lir/postalloc.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,9 +1054,6 @@ RewriteResult rewriteMemoryInputsToReg(instr_iter_t instr_iter) {
10541054
case Instruction::kMovConstPool:
10551055
case Instruction::kPush:
10561056
case Instruction::kPop:
1057-
case Instruction::kCdq:
1058-
case Instruction::kCwd:
1059-
case Instruction::kCqo:
10601057
case Instruction::kBranch:
10611058
case Instruction::kBranchNZ:
10621059
case Instruction::kBranchZ:
@@ -1099,6 +1096,12 @@ RewriteResult rewriteMemoryInputsToReg(instr_iter_t instr_iter) {
10991096
case Instruction::kCmpBranchNonZero:
11001097
case Instruction::kCallSiteLiveValues:
11011098
return kUnchanged;
1099+
#if defined(CINDER_X86_64)
1100+
case Instruction::kX64Cdq:
1101+
case Instruction::kX64Cwd:
1102+
case Instruction::kX64Cqo:
1103+
return kUnchanged;
1104+
#endif
11021105
}
11031106

11041107
auto block = instr->basicblock();
@@ -1357,13 +1360,13 @@ RewriteResult rewriteDivide(instr_iter_t instr_iter) {
13571360
Instruction::Opcode extend;
13581361
switch (dividend_lower->sizeInBits()) {
13591362
case 16:
1360-
extend = Instruction::kCwd;
1363+
extend = Instruction::kX64Cwd;
13611364
break;
13621365
case 32:
1363-
extend = Instruction::kCdq;
1366+
extend = Instruction::kX64Cdq;
13641367
break;
13651368
case 64:
1366-
extend = Instruction::kCqo;
1369+
extend = Instruction::kX64Cqo;
13671370
break;
13681371
default:
13691372
Py_UNREACHABLE();

cinderx/RuntimeTests/lir_abi_test.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -898,19 +898,19 @@ TEST_F(LIRABITest, TestkPop_Mem) {
898898
}
899899

900900
#if defined(CINDER_X86_64)
901-
// kCdq R r
901+
// kX64Cdq R r
902902
TEST_F(LIRABITest, TestkCdq_OutPhyReg_PhyReg) {
903-
translateInstr(Instruction::kCdq, makeOutPhyReg(), makePhyReg());
903+
translateInstr(Instruction::kX64Cdq, makeOutPhyReg(), makePhyReg());
904904
}
905905

906-
// kCwd R r
906+
// kX64Cwd R r
907907
TEST_F(LIRABITest, TestkCwd_OutPhyReg_PhyReg) {
908-
translateInstr(Instruction::kCwd, makeOutPhyReg(), makePhyReg());
908+
translateInstr(Instruction::kX64Cwd, makeOutPhyReg(), makePhyReg());
909909
}
910910

911-
// kCqo R r
911+
// kX64Cqo R r
912912
TEST_F(LIRABITest, TestkCqo_OutPhyReg_PhyReg) {
913-
translateInstr(Instruction::kCqo, makeOutPhyReg(), makePhyReg());
913+
translateInstr(Instruction::kX64Cqo, makeOutPhyReg(), makePhyReg());
914914
}
915915
#endif
916916

0 commit comments

Comments
 (0)