Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Side by Side Diff: src/IceTargetLoweringX8632.cpp

Issue 701673002: Subzero: Implement switch lowering for i64. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove RUIN line Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/switch-opt.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the TargetLoweringX8632 class, which 10 // This file implements the TargetLoweringX8632 class, which
(...skipping 4012 matching lines...) Expand 10 before | Expand all | Expand 10 after
4023 Shift, SegmentReg); 4023 Shift, SegmentReg);
4024 Context.insert(InstStore::create(Func, Data, Addr)); 4024 Context.insert(InstStore::create(Func, Data, Addr));
4025 } 4025 }
4026 } 4026 }
4027 4027
4028 void TargetX8632::lowerSwitch(const InstSwitch *Inst) { 4028 void TargetX8632::lowerSwitch(const InstSwitch *Inst) {
4029 // This implements the most naive possible lowering. 4029 // This implements the most naive possible lowering.
4030 // cmp a,val[0]; jeq label[0]; cmp a,val[1]; jeq label[1]; ... jmp default 4030 // cmp a,val[0]; jeq label[0]; cmp a,val[1]; jeq label[1]; ... jmp default
4031 Operand *Src0 = Inst->getComparison(); 4031 Operand *Src0 = Inst->getComparison();
4032 SizeT NumCases = Inst->getNumCases(); 4032 SizeT NumCases = Inst->getNumCases();
4033 if (Src0->getType() == IceType_i64) {
4034 Src0 = legalize(Src0); // get Base/Index into physical registers
4035 Operand *Src0Lo = loOperand(Src0);
4036 Operand *Src0Hi = hiOperand(Src0);
4037 if (NumCases >= 2) {
4038 Src0Lo = legalizeToVar(Src0Lo);
4039 Src0Hi = legalizeToVar(Src0Hi);
4040 } else {
4041 Src0Lo = legalize(Src0Lo, Legal_Reg | Legal_Mem);
4042 Src0Hi = legalize(Src0Hi, Legal_Reg | Legal_Mem);
4043 }
4044 for (SizeT I = 0; I < NumCases; ++I) {
4045 Constant *ValueLo = Ctx->getConstantInt32(IceType_i32, Inst->getValue(I));
4046 Constant *ValueHi =
4047 Ctx->getConstantInt32(IceType_i32, Inst->getValue(I) >> 32);
4048 InstX8632Label *Label = InstX8632Label::create(Func, this);
4049 _cmp(Src0Lo, ValueLo);
4050 _br(CondX86::Br_ne, Label);
4051 _cmp(Src0Hi, ValueHi);
4052 _br(CondX86::Br_e, Inst->getLabel(I));
4053 Context.insert(Label);
4054 }
4055 _br(Inst->getLabelDefault());
4056 return;
4057 }
4033 // OK, we'll be slightly less naive by forcing Src into a physical 4058 // OK, we'll be slightly less naive by forcing Src into a physical
4034 // register if there are 2 or more uses. 4059 // register if there are 2 or more uses.
4035 if (NumCases >= 2) 4060 if (NumCases >= 2)
4036 Src0 = legalizeToVar(Src0, true); 4061 Src0 = legalizeToVar(Src0);
4037 else 4062 else
4038 Src0 = legalize(Src0, Legal_Reg | Legal_Mem); 4063 Src0 = legalize(Src0, Legal_Reg | Legal_Mem);
4039 for (SizeT I = 0; I < NumCases; ++I) { 4064 for (SizeT I = 0; I < NumCases; ++I) {
4040 // TODO(stichnot): Correct lowering for IceType_i64.
4041 Constant *Value = Ctx->getConstantInt32(IceType_i32, Inst->getValue(I)); 4065 Constant *Value = Ctx->getConstantInt32(IceType_i32, Inst->getValue(I));
4042 _cmp(Src0, Value); 4066 _cmp(Src0, Value);
4043 _br(CondX86::Br_e, Inst->getLabel(I)); 4067 _br(CondX86::Br_e, Inst->getLabel(I));
4044 } 4068 }
4045 4069
4046 _br(Inst->getLabelDefault()); 4070 _br(Inst->getLabelDefault());
4047 } 4071 }
4048 4072
4049 void TargetX8632::scalarizeArithmetic(InstArithmetic::OpKind Kind, 4073 void TargetX8632::scalarizeArithmetic(InstArithmetic::OpKind Kind,
4050 Variable *Dest, Operand *Src0, 4074 Variable *Dest, Operand *Src0,
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
4700 } else if (IsConstant || IsExternal) 4724 } else if (IsConstant || IsExternal)
4701 Str << "\t.zero\t" << Size << "\n"; 4725 Str << "\t.zero\t" << Size << "\n";
4702 // Size is part of .comm. 4726 // Size is part of .comm.
4703 4727
4704 if (IsConstant || HasNonzeroInitializer || IsExternal) 4728 if (IsConstant || HasNonzeroInitializer || IsExternal)
4705 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; 4729 Str << "\t.size\t" << MangledName << ", " << Size << "\n";
4706 // Size is part of .comm. 4730 // Size is part of .comm.
4707 } 4731 }
4708 4732
4709 } // end of namespace Ice 4733 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | tests_lit/llvm2ice_tests/switch-opt.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698