mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[TableGen] Use sign rotated VBR for OPC_EmitInteger.
This allows for a much more efficient encoding for small negative numbers by storing the sign bit first and negating the rest of the bits. This was already being used for OPC_CheckInteger. For every in tree target this affects, the table got smaller. R600GenDAGISel.inc saw the largest reduction of 7K. I did have to add a new opcode for StringIntegers used for register class ids and subregister indices since we don't have the integer value to encode. The enum name is emitted directly into the table. Previously assumed the enum would expand to a positive 7-bit number. We might be able to just shift that right by 1 and assume it is a positive 6 bit number, but that will need more investigation.
This commit is contained in:
parent
3b8bc4cd8f
commit
b555d38aa1
@ -149,6 +149,7 @@ public:
|
||||
OPC_CheckFoldableChainNode,
|
||||
|
||||
OPC_EmitInteger,
|
||||
OPC_EmitStringInteger,
|
||||
OPC_EmitRegister,
|
||||
OPC_EmitRegister2,
|
||||
OPC_EmitConvertToTarget,
|
||||
|
@ -3280,12 +3280,15 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
|
||||
|
||||
continue;
|
||||
}
|
||||
case OPC_EmitInteger: {
|
||||
case OPC_EmitInteger:
|
||||
case OPC_EmitStringInteger: {
|
||||
MVT::SimpleValueType VT =
|
||||
(MVT::SimpleValueType)MatcherTable[MatcherIndex++];
|
||||
int64_t Val = MatcherTable[MatcherIndex++];
|
||||
if (Val & 128)
|
||||
Val = GetVBR(Val, MatcherTable, MatcherIndex);
|
||||
if (Opcode == OPC_EmitInteger)
|
||||
Val = decodeSignRotatedValue(Val);
|
||||
RecordedNodes.push_back(std::pair<SDValue, SDNode*>(
|
||||
CurDAG->getTargetConstant(Val, SDLoc(NodeToMatch),
|
||||
VT), nullptr));
|
||||
|
@ -83,7 +83,7 @@ def MulIRRPat : Pat<(mul i32:$x, i32:$y), (MulIRR Reg:$x, Reg:$y)>;
|
||||
// ADDINT-NEXT: OPC_CheckChild0Integer
|
||||
// ADDINT-NEXT: OPC_RecordChild1
|
||||
// ADDINT-NEXT: OPC_RecordChild2
|
||||
// ADDINT-NEXT: OPC_EmitInteger, MVT::i32, 1
|
||||
// ADDINT-NEXT: OPC_EmitInteger, MVT::i32, 2
|
||||
// ADDINT-NEXT: OPC_MorphNodeTo1, TARGET_VAL(::AddRRI)
|
||||
|
||||
// SUB: SwitchOpcode{{.*}}TARGET_VAL(ISD::SUB)
|
||||
|
@ -25,14 +25,14 @@ def GPRAbove127 : RegisterClass<"TestTarget", [i32], 32,
|
||||
// CHECK-NEXT: OPC_RecordChild0, // #0 = $src
|
||||
// CHECK-NEXT: OPC_Scope, 14, /*->20*/ // 2 children in Scope
|
||||
// CHECK-NEXT: OPC_CheckChild1Integer, 0,
|
||||
// CHECK-NEXT: OPC_EmitInteger, MVT::i32, 0|128,1/*128*/,
|
||||
// CHECK-NEXT: OPC_EmitInteger, MVT::i32, 0|128,2/*256*/,
|
||||
// CHECK-NEXT: OPC_MorphNodeTo1, TARGET_VAL(TargetOpcode::COPY_TO_REGCLASS), 0,
|
||||
// CHECK-NEXT: MVT::i32, 2/*#Ops*/, 1, 0,
|
||||
def : Pat<(i32 (add i32:$src, (i32 0))),
|
||||
(COPY_TO_REGCLASS GPRAbove127, GPR0:$src)>;
|
||||
|
||||
// CHECK: OPC_CheckChild1Integer, 2,
|
||||
// CHECK-NEXT: OPC_EmitInteger, MVT::i32, TestNamespace::GPR127RegClassID,
|
||||
// CHECK-NEXT: OPC_EmitStringInteger, MVT::i32, TestNamespace::GPR127RegClassID,
|
||||
// CHECK-NEXT: OPC_MorphNodeTo1, TARGET_VAL(TargetOpcode::COPY_TO_REGCLASS), 0,
|
||||
// CHECK-NEXT: MVT::i32, 2/*#Ops*/, 1, 0,
|
||||
def : Pat<(i32 (add i32:$src, (i32 1))),
|
||||
|
@ -4,11 +4,11 @@ include "reg-with-subregs-common.td"
|
||||
|
||||
// CHECK-LABEL: OPC_CheckOpcode, TARGET_VAL(ISD::EXTRACT_SUBVECTOR),
|
||||
// CHECK: OPC_CheckChild1Integer, 0,
|
||||
// CHECK: OPC_EmitInteger, MVT::i32, sub0_sub1,
|
||||
// CHECK: OPC_EmitStringInteger, MVT::i32, sub0_sub1,
|
||||
def : Pat<(v2i32 (extract_subvector v32i32:$src, (i32 0))),
|
||||
(EXTRACT_SUBREG GPR_1024:$src, sub0_sub1)>;
|
||||
|
||||
// CHECK: OPC_CheckChild1Integer, 30,
|
||||
// CHECK: OPC_EmitInteger, MVT::i32, 5|128,1/*133*/,
|
||||
// CHECK: OPC_EmitInteger, MVT::i32, 10|128,2/*266*/,
|
||||
def : Pat<(v2i32 (extract_subvector v32i32:$src, (i32 15))),
|
||||
(EXTRACT_SUBREG GPR_1024:$src, sub30_sub31)>;
|
||||
|
@ -668,16 +668,16 @@ EmitMatcher(const Matcher *N, const unsigned Indent, unsigned CurrentIdx,
|
||||
int64_t Val = cast<EmitIntegerMatcher>(N)->getValue();
|
||||
OS << "OPC_EmitInteger, "
|
||||
<< getEnumName(cast<EmitIntegerMatcher>(N)->getVT()) << ", ";
|
||||
unsigned Bytes = 2+EmitVBRValue(Val, OS);
|
||||
unsigned Bytes = 2 + EmitSignedVBRValue(Val, OS);
|
||||
OS << '\n';
|
||||
return Bytes;
|
||||
}
|
||||
case Matcher::EmitStringInteger: {
|
||||
const std::string &Val = cast<EmitStringIntegerMatcher>(N)->getValue();
|
||||
// These should always fit into 7 bits.
|
||||
OS << "OPC_EmitInteger, "
|
||||
<< getEnumName(cast<EmitStringIntegerMatcher>(N)->getVT()) << ", "
|
||||
<< Val << ",\n";
|
||||
OS << "OPC_EmitStringInteger, "
|
||||
<< getEnumName(cast<EmitStringIntegerMatcher>(N)->getVT()) << ", " << Val
|
||||
<< ",\n";
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user