Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 7193f5e

Browse files
committed
[CodeGen] Shrink MachineOperand by 8 bytes on Windows
Use 'unsigned' for these bitfields so they actually pack together. Previously it used three words for these bits instead of one. Add some static_asserts to prevent this from being undone. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323135 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent a7bc888 commit 7193f5e

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

include/llvm/CodeGen/MachineOperand.h

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class MachineOperand {
7474
private:
7575
/// OpKind - Specify what kind of operand this is. This discriminates the
7676
/// union.
77-
MachineOperandType OpKind : 8;
77+
unsigned OpKind : 8;
7878

7979
/// Subregister number for MO_Register. A value of 0 indicates the
8080
/// MO_Register has no subReg.
@@ -85,32 +85,32 @@ class MachineOperand {
8585
/// TiedTo - Non-zero when this register operand is tied to another register
8686
/// operand. The encoding of this field is described in the block comment
8787
/// before MachineInstr::tieOperands().
88-
unsigned char TiedTo : 4;
88+
unsigned TiedTo : 4;
8989

9090
/// IsDef - True if this is a def, false if this is a use of the register.
9191
/// This is only valid on register operands.
9292
///
93-
bool IsDef : 1;
93+
unsigned IsDef : 1;
9494

9595
/// IsImp - True if this is an implicit def or use, false if it is explicit.
9696
/// This is only valid on register opderands.
9797
///
98-
bool IsImp : 1;
98+
unsigned IsImp : 1;
9999

100100
/// IsDeadOrKill
101101
/// For uses: IsKill - True if this instruction is the last use of the
102102
/// register on this path through the function.
103103
/// For defs: IsDead - True if this register is never used by a subsequent
104104
/// instruction.
105105
/// This is only valid on register operands.
106-
bool IsDeadOrKill : 1;
106+
unsigned IsDeadOrKill : 1;
107107

108108
/// IsRenamable - True if this register may be renamed, i.e. it does not
109109
/// generate a value that is somehow read in a way that is not represented by
110110
/// the Machine IR (e.g. to meet an ABI or ISA requirement). This is only
111111
/// valid on physical register operands. Virtual registers are assumed to
112112
/// always be renamable regardless of the value of this field.
113-
bool IsRenamable : 1;
113+
unsigned IsRenamable : 1;
114114

115115
/// IsUndef - True if this register operand reads an "undef" value, i.e. the
116116
/// read value doesn't matter. This flag can be set on both use and def
@@ -129,7 +129,7 @@ class MachineOperand {
129129
/// Any register can be used for %2, and its value doesn't matter, but
130130
/// the two operands must be the same register.
131131
///
132-
bool IsUndef : 1;
132+
unsigned IsUndef : 1;
133133

134134
/// IsInternalRead - True if this operand reads a value that was defined
135135
/// inside the same instruction or bundle. This flag can be set on both use
@@ -140,16 +140,16 @@ class MachineOperand {
140140
/// When this flag is set, the instruction bundle must contain at least one
141141
/// other def of the register. If multiple instructions in the bundle define
142142
/// the register, the meaning is target-defined.
143-
bool IsInternalRead : 1;
143+
unsigned IsInternalRead : 1;
144144

145145
/// IsEarlyClobber - True if this MO_Register 'def' operand is written to
146146
/// by the MachineInstr before all input registers are read. This is used to
147147
/// model the GCC inline asm '&' constraint modifier.
148-
bool IsEarlyClobber : 1;
148+
unsigned IsEarlyClobber : 1;
149149

150150
/// IsDebug - True if this MO_Register 'use' operand is in a debug pseudo,
151151
/// not a real instruction. Such uses should be ignored during codegen.
152-
bool IsDebug : 1;
152+
unsigned IsDebug : 1;
153153

154154
/// SmallContents - This really should be part of the Contents union, but
155155
/// lives out here so we can get a better packed struct.
@@ -198,7 +198,19 @@ class MachineOperand {
198198
} Contents;
199199

200200
explicit MachineOperand(MachineOperandType K)
201-
: OpKind(K), SubReg_TargetFlags(0), ParentMI(nullptr) {}
201+
: OpKind(K), SubReg_TargetFlags(0), ParentMI(nullptr) {
202+
// Assert that the layout is what we expect. It's easy to grow this object.
203+
static_assert(alignof(MachineOperand) <= alignof(int64_t),
204+
"MachineOperand shouldn't be more than 8 byte aligned");
205+
static_assert(sizeof(Contents) <= 2 * sizeof(void *),
206+
"Contents should be at most two pointers");
207+
static_assert(sizeof(MachineOperand) <=
208+
alignTo<alignof(int64_t)>(2 * sizeof(unsigned) +
209+
3 * sizeof(void *)),
210+
"MachineOperand too big. Should be Kind, SmallContents, "
211+
"ParentMI, and Contents");
212+
}
213+
202214
public:
203215
/// getType - Returns the MachineOperandType for this operand.
204216
///

0 commit comments

Comments
 (0)