mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-13 22:58:50 +00:00
Emit switches with 1/2 cases as unconditional code or an if/then/else for
tidyness. llvm-svn: 29181
This commit is contained in:
parent
b84950e599
commit
2c14435831
@ -560,18 +560,32 @@ void AsmWriterEmitter::run(std::ostream &O) {
|
||||
BitsLeft -= NumBits;
|
||||
|
||||
O << "\n // Fragment " << i << " encoded into " << NumBits
|
||||
<< " bits for " << Commands.size() << " unique commands.\n"
|
||||
<< " switch ((Bits >> " << (BitsLeft+AsmStrBits) << ") & "
|
||||
<< ((1 << NumBits)-1) << ") {\n"
|
||||
<< " default: // unreachable.\n";
|
||||
<< " bits for " << Commands.size() << " unique commands.\n";
|
||||
|
||||
// Print out all the cases.
|
||||
for (unsigned i = 0, e = Commands.size(); i != e; ++i) {
|
||||
O << " case " << i << ":\n";
|
||||
O << Commands[i];
|
||||
O << " break;\n";
|
||||
if (Commands.size() == 1) {
|
||||
// Only one possibility, just emit it.
|
||||
O << Commands[0];
|
||||
} else if (Commands.size() == 2) {
|
||||
// Emit two possibilitys with if/else.
|
||||
O << " if ((Bits >> " << (BitsLeft+AsmStrBits) << ") & "
|
||||
<< ((1 << NumBits)-1) << ") {\n"
|
||||
<< Commands[1]
|
||||
<< " } else {\n"
|
||||
<< Commands[0]
|
||||
<< " }\n\n";
|
||||
} else {
|
||||
O << " switch ((Bits >> " << (BitsLeft+AsmStrBits) << ") & "
|
||||
<< ((1 << NumBits)-1) << ") {\n"
|
||||
<< " default: // unreachable.\n";
|
||||
|
||||
// Print out all the cases.
|
||||
for (unsigned i = 0, e = Commands.size(); i != e; ++i) {
|
||||
O << " case " << i << ":\n";
|
||||
O << Commands[i];
|
||||
O << " break;\n";
|
||||
}
|
||||
O << " }\n\n";
|
||||
}
|
||||
O << " }\n\n";
|
||||
}
|
||||
|
||||
// Okay, go through and strip out the operand information that we just
|
||||
|
Loading…
Reference in New Issue
Block a user