[PATCH] D93326: [MCInstrDesc] [TableGen] Reduce size of MCOperandInfo instances
Paul C. Anagnostopoulos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 19 11:41:00 PST 2020
Paul-C-Anagnostopoulos updated this revision to Diff 312945.
Paul-C-Anagnostopoulos added a comment.
Let's try this again.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93326/new/
https://reviews.llvm.org/D93326
Files:
llvm/include/llvm/MC/MCInstrDesc.h
llvm/utils/TableGen/InstrInfoEmitter.cpp
Index: llvm/utils/TableGen/InstrInfoEmitter.cpp
===================================================================
--- llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -182,11 +182,10 @@
if (Constraint.isNone())
Res += "0";
else if (Constraint.isEarlyClobber())
- Res += "(1 << MCOI::EARLY_CLOBBER)";
+ Res += "MCOI_EARLY_CLOBBER(1)";
else {
assert(Constraint.isTied());
- Res += "((" + utostr(Constraint.getTiedOperand()) +
- " << 16) | (1 << MCOI::TIED_TO))";
+ Res += "MCOI_TIED_TO(" + utostr(Constraint.getTiedOperand()) + ")";
}
Result.push_back(Res);
Index: llvm/include/llvm/MC/MCInstrDesc.h
===================================================================
--- llvm/include/llvm/MC/MCInstrDesc.h
+++ llvm/include/llvm/MC/MCInstrDesc.h
@@ -27,12 +27,22 @@
//===----------------------------------------------------------------------===//
namespace MCOI {
-// Operand constraints
+/// Operand constraints. These are encoded in 16 bits with one of the
+/// low-order 3 bits specifying that a constraint is present and the
+/// corresponding high-order hex digit specifying the constraint value.
+/// This allows for a maximum of 3 constraints.
enum OperandConstraint {
- TIED_TO = 0, // Must be allocated the same register as.
- EARLY_CLOBBER // Operand is an early clobber register operand
+ TIED_TO = 0, // Must be allocated the same register as specified value.
+ EARLY_CLOBBER // Operand is an early clobber register.
};
+// Define a macro to produce each constraint value.
+#define MCOI_TIED_TO(op) \
+ ((1 << MCOI::TIED_TO) | ((op) << (4 + MCOI::TIED_TO * 4)))
+
+#define MCOI_EARLY_CLOBBER(bit) \
+ ((1 << MCOI::EARLY_CLOBBER) | ((bit) << (4 + MCOI::EARLY_CLOBBER * 4)))
+
/// These are flags set on operands, but should be considered
/// private, all access should go through the MCOperandInfo accessors.
/// See the accessors for a description of what these are.
@@ -84,10 +94,9 @@
/// Information about the type of the operand.
uint8_t OperandType;
- /// The lower 16 bits are used to specify which constraints are set.
- /// The higher 16 bits are used to specify the value of constraints (4 bits
- /// each).
- uint32_t Constraints;
+
+ /// Operand constraints (see OperandConstraint enum).
+ uint16_t Constraints;
/// Set if this operand is a pointer value and it requires a callback
/// to look up its register class.
@@ -197,14 +206,14 @@
const MCPhysReg *ImplicitDefs; // Registers implicitly defined by this instr
const MCOperandInfo *OpInfo; // 'NumOperands' entries about operands
- /// Returns the value of the specific constraint if
- /// it is set. Returns -1 if it is not set.
+ /// Returns the value of the specified operand constraint if
+ /// it is present. Returns -1 if it is not present.
int getOperandConstraint(unsigned OpNum,
MCOI::OperandConstraint Constraint) const {
if (OpNum < NumOperands &&
(OpInfo[OpNum].Constraints & (1 << Constraint))) {
- unsigned Pos = 16 + Constraint * 4;
- return (int)(OpInfo[OpNum].Constraints >> Pos) & 0xf;
+ unsigned ValuePos = 4 + Constraint * 4;
+ return (int)(OpInfo[OpNum].Constraints >> ValuePos) & 0x0f;
}
return -1;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93326.312945.patch
Type: text/x-patch
Size: 3375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201219/7006156a/attachment.bin>
More information about the llvm-commits
mailing list