mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Emit switches with 1/2 cases as unconditional code or an if/then/else for
tidyness. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29181 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -560,8 +560,21 @@ 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) << ") & "
|
||||
<< " bits for " << Commands.size() << " unique commands.\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";
|
||||
|
||||
@@ -573,6 +586,7 @@ void AsmWriterEmitter::run(std::ostream &O) {
|
||||
}
|
||||
O << " }\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Okay, go through and strip out the operand information that we just
|
||||
// emitted.
|
||||
|
Reference in New Issue
Block a user