Chromium Code Reviews| Index: src/IceTargetLoweringARM32.cpp |
| diff --git a/src/IceTargetLoweringARM32.cpp b/src/IceTargetLoweringARM32.cpp |
| index 9bb2386b387ff42631ad4dce6e8361e1f7b0e7f9..009ddbfef06312de11a29e5996d6c88121d95441 100644 |
| --- a/src/IceTargetLoweringARM32.cpp |
| +++ b/src/IceTargetLoweringARM32.cpp |
| @@ -1925,8 +1925,35 @@ void TargetARM32::doAddressOptStore() { |
| } |
| void TargetARM32::lowerSwitch(const InstSwitch *Inst) { |
| - (void)Inst; |
| - UnimplementedError(Func->getContext()->getFlags()); |
| + // This implements the most naive possible lowering. |
| + // cmp a,val[0]; jeq label[0]; cmp a,val[1]; jeq label[1]; ... jmp default |
| + Operand *Src0 = Inst->getComparison(); |
| + SizeT NumCases = Inst->getNumCases(); |
| + if (Src0->getType() == IceType_i64) { |
| + Variable *Src0Lo = legalizeToVar(loOperand(Src0)); |
|
jvoung (off chromium)
2015/06/25 21:24:50
Hmm maybe why the X86 version had "legalize(Src0);
jvoung (off chromium)
2015/06/29 16:51:47
Well, there are other places in the ARM code which
ascull
2015/06/29 17:00:03
Done.
|
| + Variable *Src0Hi = legalizeToVar(hiOperand(Src0)); |
| + for (SizeT I = 0; I < NumCases; ++I) { |
| + Operand *ValueLo = Ctx->getConstantInt32(Inst->getValue(I)); |
| + Operand *ValueHi = Ctx->getConstantInt32(Inst->getValue(I) >> 32); |
| + ValueLo = legalize(ValueLo, Legal_Reg | Legal_Flex); |
| + ValueHi = legalize(ValueHi, Legal_Reg | Legal_Flex); |
| + _cmp(Src0Lo, ValueLo); |
| + _cmp(Src0Hi, ValueHi, CondARM32::EQ); |
|
jvoung (off chromium)
2015/06/25 21:24:50
nice, use that predication =)
|
| + _br(Inst->getLabel(I), CondARM32::EQ); |
| + } |
| + _br(Inst->getLabelDefault()); |
| + return; |
| + } |
| + |
| + // 32 bit integer |
| + Variable *Src0Var = legalizeToVar(Src0); |
| + for (SizeT I = 0; I < NumCases; ++I) { |
| + Operand *Value = Ctx->getConstantInt32(Inst->getValue(I)); |
| + Value = legalize(Value, Legal_Reg | Legal_Flex); |
| + _cmp(Src0Var, Value); |
| + _br(Inst->getLabel(I), CondARM32::EQ); |
| + } |
| + _br(Inst->getLabelDefault()); |
| } |
| void TargetARM32::lowerUnreachable(const InstUnreachable * /*Inst*/) { |