Skip to content

Commit d38a5af

Browse files
authored
[NFC][MC][ARM] Fix formatting for ITStatus and VPTStatus (#154815)
1 parent 04a271a commit d38a5af

File tree

1 file changed

+66
-80
lines changed

1 file changed

+66
-80
lines changed

llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp

Lines changed: 66 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -38,94 +38,80 @@ using DecodeStatus = MCDisassembler::DecodeStatus;
3838

3939
namespace {
4040

41-
// Handles the condition code status of instructions in IT blocks
42-
class ITStatus
43-
{
44-
public:
45-
// Returns the condition code for instruction in IT block
46-
unsigned getITCC() {
47-
unsigned CC = ARMCC::AL;
48-
if (instrInITBlock())
49-
CC = ITStates.back();
50-
return CC;
51-
}
52-
53-
// Advances the IT block state to the next T or E
54-
void advanceITState() {
55-
ITStates.pop_back();
56-
}
57-
58-
// Returns true if the current instruction is in an IT block
59-
bool instrInITBlock() {
60-
return !ITStates.empty();
61-
}
62-
63-
// Returns true if current instruction is the last instruction in an IT block
64-
bool instrLastInITBlock() {
65-
return ITStates.size() == 1;
66-
}
67-
68-
// Called when decoding an IT instruction. Sets the IT state for
69-
// the following instructions that for the IT block. Firstcond
70-
// corresponds to the field in the IT instruction encoding; Mask
71-
// is in the MCOperand format in which 1 means 'else' and 0 'then'.
72-
void setITState(char Firstcond, char Mask) {
73-
// (3 - the number of trailing zeros) is the number of then / else.
74-
unsigned NumTZ = llvm::countr_zero<uint8_t>(Mask);
75-
unsigned char CCBits = static_cast<unsigned char>(Firstcond & 0xf);
76-
assert(NumTZ <= 3 && "Invalid IT mask!");
77-
// push condition codes onto the stack the correct order for the pops
78-
for (unsigned Pos = NumTZ+1; Pos <= 3; ++Pos) {
79-
unsigned Else = (Mask >> Pos) & 1;
80-
ITStates.push_back(CCBits ^ Else);
81-
}
82-
ITStates.push_back(CCBits);
83-
}
41+
// Handles the condition code status of instructions in IT blocks
42+
class ITStatus {
43+
public:
44+
// Returns the condition code for instruction in IT block
45+
unsigned getITCC() {
46+
unsigned CC = ARMCC::AL;
47+
if (instrInITBlock())
48+
CC = ITStates.back();
49+
return CC;
50+
}
51+
52+
// Advances the IT block state to the next T or E
53+
void advanceITState() { ITStates.pop_back(); }
54+
55+
// Returns true if the current instruction is in an IT block
56+
bool instrInITBlock() { return !ITStates.empty(); }
57+
58+
// Returns true if current instruction is the last instruction in an IT block
59+
bool instrLastInITBlock() { return ITStates.size() == 1; }
60+
61+
// Called when decoding an IT instruction. Sets the IT state for
62+
// the following instructions that for the IT block. Firstcond
63+
// corresponds to the field in the IT instruction encoding; Mask
64+
// is in the MCOperand format in which 1 means 'else' and 0 'then'.
65+
void setITState(char Firstcond, char Mask) {
66+
// (3 - the number of trailing zeros) is the number of then / else.
67+
unsigned NumTZ = llvm::countr_zero<uint8_t>(Mask);
68+
unsigned char CCBits = static_cast<unsigned char>(Firstcond & 0xf);
69+
assert(NumTZ <= 3 && "Invalid IT mask!");
70+
// push condition codes onto the stack the correct order for the pops
71+
for (unsigned Pos = NumTZ + 1; Pos <= 3; ++Pos) {
72+
unsigned Else = (Mask >> Pos) & 1;
73+
ITStates.push_back(CCBits ^ Else);
74+
}
75+
ITStates.push_back(CCBits);
76+
}
8477

85-
private:
86-
std::vector<unsigned char> ITStates;
87-
};
78+
private:
79+
std::vector<unsigned char> ITStates;
80+
};
8881

89-
class VPTStatus
90-
{
91-
public:
92-
unsigned getVPTPred() {
93-
unsigned Pred = ARMVCC::None;
94-
if (instrInVPTBlock())
95-
Pred = VPTStates.back();
96-
return Pred;
97-
}
82+
class VPTStatus {
83+
public:
84+
unsigned getVPTPred() {
85+
unsigned Pred = ARMVCC::None;
86+
if (instrInVPTBlock())
87+
Pred = VPTStates.back();
88+
return Pred;
89+
}
9890

99-
void advanceVPTState() {
100-
VPTStates.pop_back();
101-
}
91+
void advanceVPTState() { VPTStates.pop_back(); }
10292

103-
bool instrInVPTBlock() {
104-
return !VPTStates.empty();
105-
}
93+
bool instrInVPTBlock() { return !VPTStates.empty(); }
10694

107-
bool instrLastInVPTBlock() {
108-
return VPTStates.size() == 1;
109-
}
95+
bool instrLastInVPTBlock() { return VPTStates.size() == 1; }
11096

111-
void setVPTState(char Mask) {
112-
// (3 - the number of trailing zeros) is the number of then / else.
113-
unsigned NumTZ = llvm::countr_zero<uint8_t>(Mask);
114-
assert(NumTZ <= 3 && "Invalid VPT mask!");
115-
// push predicates onto the stack the correct order for the pops
116-
for (unsigned Pos = NumTZ+1; Pos <= 3; ++Pos) {
117-
bool T = ((Mask >> Pos) & 1) == 0;
118-
if (T)
119-
VPTStates.push_back(ARMVCC::Then);
120-
else
121-
VPTStates.push_back(ARMVCC::Else);
122-
}
97+
void setVPTState(char Mask) {
98+
// (3 - the number of trailing zeros) is the number of then / else.
99+
unsigned NumTZ = llvm::countr_zero<uint8_t>(Mask);
100+
assert(NumTZ <= 3 && "Invalid VPT mask!");
101+
// push predicates onto the stack the correct order for the pops
102+
for (unsigned Pos = NumTZ + 1; Pos <= 3; ++Pos) {
103+
bool T = ((Mask >> Pos) & 1) == 0;
104+
if (T)
123105
VPTStates.push_back(ARMVCC::Then);
124-
}
106+
else
107+
VPTStates.push_back(ARMVCC::Else);
108+
}
109+
VPTStates.push_back(ARMVCC::Then);
110+
}
125111

126-
private:
127-
SmallVector<unsigned char, 4> VPTStates;
128-
};
112+
private:
113+
SmallVector<unsigned char, 4> VPTStates;
114+
};
129115

130116
/// ARM disassembler for all ARM platforms.
131117
class ARMDisassembler : public MCDisassembler {

0 commit comments

Comments
 (0)