OLD | NEW |
---|---|
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 | 100 |
101 CondX86::BrCond getIcmp32Mapping(InstIcmp::ICond Cond) { | 101 CondX86::BrCond getIcmp32Mapping(InstIcmp::ICond Cond) { |
102 size_t Index = static_cast<size_t>(Cond); | 102 size_t Index = static_cast<size_t>(Cond); |
103 assert(Index < TableIcmp32Size); | 103 assert(Index < TableIcmp32Size); |
104 return TableIcmp32[Index].Mapping; | 104 return TableIcmp32[Index].Mapping; |
105 } | 105 } |
106 | 106 |
107 const struct TableTypeX8632Attributes_ { | 107 const struct TableTypeX8632Attributes_ { |
108 Type InVectorElementType; | 108 Type InVectorElementType; |
109 } TableTypeX8632Attributes[] = { | 109 } TableTypeX8632Attributes[] = { |
110 #define X(tag, elementty, cvt, sdss, pack, width) \ | 110 #define X(tag, elementty, cvt, sdss, pack, width, fld) \ |
111 { elementty } \ | 111 { elementty } \ |
112 , | 112 , |
113 ICETYPEX8632_TABLE | 113 ICETYPEX8632_TABLE |
114 #undef X | 114 #undef X |
115 }; | 115 }; |
116 const size_t TableTypeX8632AttributesSize = | 116 const size_t TableTypeX8632AttributesSize = |
117 llvm::array_lengthof(TableTypeX8632Attributes); | 117 llvm::array_lengthof(TableTypeX8632Attributes); |
118 | 118 |
119 // Return the type which the elements of the vector have in the X86 | 119 // Return the type which the elements of the vector have in the X86 |
120 // representation of the vector. | 120 // representation of the vector. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 "Inconsistency between ICMPX8632_TABLE and ICEINSTICMP_TABLE"); | 238 "Inconsistency between ICMPX8632_TABLE and ICEINSTICMP_TABLE"); |
239 ICEINSTICMP_TABLE; | 239 ICEINSTICMP_TABLE; |
240 #undef X | 240 #undef X |
241 } // end of namespace dummy2 | 241 } // end of namespace dummy2 |
242 | 242 |
243 // Validate the enum values in ICETYPEX8632_TABLE. | 243 // Validate the enum values in ICETYPEX8632_TABLE. |
244 namespace dummy3 { | 244 namespace dummy3 { |
245 // Define a temporary set of enum values based on low-level table | 245 // Define a temporary set of enum values based on low-level table |
246 // entries. | 246 // entries. |
247 enum _tmp_enum { | 247 enum _tmp_enum { |
248 #define X(tag, elementty, cvt, sdss, pack, width) _tmp_##tag, | 248 #define X(tag, elementty, cvt, sdss, pack, width, fld) _tmp_##tag, |
249 ICETYPEX8632_TABLE | 249 ICETYPEX8632_TABLE |
250 #undef X | 250 #undef X |
251 _num | 251 _num |
252 }; | 252 }; |
253 // Define a set of constants based on high-level table entries. | 253 // Define a set of constants based on high-level table entries. |
254 #define X(tag, size, align, elts, elty, str) \ | 254 #define X(tag, size, align, elts, elty, str) \ |
255 static const int _table1_##tag = tag; | 255 static const int _table1_##tag = tag; |
256 ICETYPE_TABLE; | 256 ICETYPE_TABLE; |
257 #undef X | 257 #undef X |
258 // Define a set of constants based on low-level table entries, and | 258 // Define a set of constants based on low-level table entries, and |
259 // ensure the table entry keys are consistent. | 259 // ensure the table entry keys are consistent. |
260 #define X(tag, elementty, cvt, sdss, pack, width) \ | 260 #define X(tag, elementty, cvt, sdss, pack, width, fld) \ |
261 static const int _table2_##tag = _tmp_##tag; \ | 261 static const int _table2_##tag = _tmp_##tag; \ |
262 static_assert(_table1_##tag == _table2_##tag, \ | 262 static_assert(_table1_##tag == _table2_##tag, \ |
263 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); | 263 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); |
264 ICETYPEX8632_TABLE; | 264 ICETYPEX8632_TABLE; |
265 #undef X | 265 #undef X |
266 // Repeat the static asserts with respect to the high-level table | 266 // Repeat the static asserts with respect to the high-level table |
267 // entries in case the high-level table has extra entries. | 267 // entries in case the high-level table has extra entries. |
268 #define X(tag, size, align, elts, elty, str) \ | 268 #define X(tag, size, align, elts, elty, str) \ |
269 static_assert(_table1_##tag == _table2_##tag, \ | 269 static_assert(_table1_##tag == _table2_##tag, \ |
270 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); | 270 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 case IceType_i16: | 502 case IceType_i16: |
503 return RegNames16[RegNum]; | 503 return RegNames16[RegNum]; |
504 default: | 504 default: |
505 return RegNames[RegNum]; | 505 return RegNames[RegNum]; |
506 } | 506 } |
507 } | 507 } |
508 | 508 |
509 void TargetX8632::emitVariable(const Variable *Var) const { | 509 void TargetX8632::emitVariable(const Variable *Var) const { |
510 Ostream &Str = Ctx->getStrEmit(); | 510 Ostream &Str = Ctx->getStrEmit(); |
511 if (Var->hasReg()) { | 511 if (Var->hasReg()) { |
512 Str << getRegName(Var->getRegNum(), Var->getType()); | 512 Str << "%" << getRegName(Var->getRegNum(), Var->getType()); |
513 return; | 513 return; |
514 } | 514 } |
515 Str << InstX8632::getWidthString(Var->getType()); | 515 const Type Ty = IceType_i32; |
516 Str << " [" << getRegName(getFrameOrStackReg(), IceType_i32); | |
517 int32_t Offset = Var->getStackOffset(); | 516 int32_t Offset = Var->getStackOffset(); |
518 if (!hasFramePointer()) | 517 if (!hasFramePointer()) |
519 Offset += getStackAdjustment(); | 518 Offset += getStackAdjustment(); |
520 if (Offset) { | 519 if (Offset) |
521 if (Offset > 0) | |
522 Str << "+"; | |
523 Str << Offset; | 520 Str << Offset; |
524 } | 521 Str << "(%" << getRegName(getFrameOrStackReg(), Ty) << ")"; |
525 Str << "]"; | |
526 } | 522 } |
527 | 523 |
528 x86::Address TargetX8632::stackVarToAsmOperand(const Variable *Var) const { | 524 x86::Address TargetX8632::stackVarToAsmOperand(const Variable *Var) const { |
529 assert(!Var->hasReg()); | 525 assert(!Var->hasReg()); |
530 int32_t Offset = Var->getStackOffset(); | 526 int32_t Offset = Var->getStackOffset(); |
531 if (!hasFramePointer()) | 527 if (!hasFramePointer()) |
532 Offset += getStackAdjustment(); | 528 Offset += getStackAdjustment(); |
533 return x86::Address(RegX8632::getEncodedGPR(getFrameOrStackReg()), Offset); | 529 return x86::Address(RegX8632::getEncodedGPR(getFrameOrStackReg()), Offset); |
534 } | 530 } |
535 | 531 |
(...skipping 4055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4591 } | 4587 } |
4592 } | 4588 } |
4593 } | 4589 } |
4594 } | 4590 } |
4595 AvailableRegisters |= FreedRegisters; | 4591 AvailableRegisters |= FreedRegisters; |
4596 } | 4592 } |
4597 } | 4593 } |
4598 | 4594 |
4599 template <> void ConstantInteger32::emit(GlobalContext *Ctx) const { | 4595 template <> void ConstantInteger32::emit(GlobalContext *Ctx) const { |
4600 Ostream &Str = Ctx->getStrEmit(); | 4596 Ostream &Str = Ctx->getStrEmit(); |
4601 Str << (int32_t)getValue(); | 4597 Str << "$" << (int32_t)getValue(); |
4602 } | 4598 } |
4603 | 4599 |
4604 template <> void ConstantInteger64::emit(GlobalContext *) const { | 4600 template <> void ConstantInteger64::emit(GlobalContext *) const { |
4605 llvm_unreachable("Not expecting to emit 64-bit integers"); | 4601 llvm_unreachable("Not expecting to emit 64-bit integers"); |
4606 } | 4602 } |
4607 | 4603 |
4608 template <> void ConstantFloat::emit(GlobalContext *Ctx) const { | 4604 template <> void ConstantFloat::emit(GlobalContext *Ctx) const { |
4609 Ostream &Str = Ctx->getStrEmit(); | 4605 Ostream &Str = Ctx->getStrEmit(); |
4610 // It would be better to prefix with ".L$" instead of "L$", but | 4606 // It would be better to prefix with ".L$" instead of "L$", but |
4611 // llvm-mc doesn't parse "dword ptr [.L$foo]". | 4607 // llvm-mc doesn't parse "dword ptr [.L$foo]". |
jvoung (off chromium)
2014/10/31 22:12:18
adjust comment about "dword ptr" ?
Jim Stichnoth
2014/11/01 13:44:17
Even better, adjusted the code to use .L$ prefix.
| |
4612 Str << "dword ptr [L$" << IceType_f32 << "$" << getPoolEntryID() << "]"; | 4608 Str << "L$" << IceType_f32 << "$" << getPoolEntryID(); |
4613 } | 4609 } |
4614 | 4610 |
4615 template <> void ConstantDouble::emit(GlobalContext *Ctx) const { | 4611 template <> void ConstantDouble::emit(GlobalContext *Ctx) const { |
4616 Ostream &Str = Ctx->getStrEmit(); | 4612 Ostream &Str = Ctx->getStrEmit(); |
4617 Str << "qword ptr [L$" << IceType_f64 << "$" << getPoolEntryID() << "]"; | 4613 Str << "L$" << IceType_f64 << "$" << getPoolEntryID(); |
4618 } | 4614 } |
4619 | 4615 |
4620 void ConstantUndef::emit(GlobalContext *) const { | 4616 void ConstantUndef::emit(GlobalContext *) const { |
4621 llvm_unreachable("undef value encountered by emitter."); | 4617 llvm_unreachable("undef value encountered by emitter."); |
4622 } | 4618 } |
4623 | 4619 |
4624 TargetGlobalInitX8632::TargetGlobalInitX8632(GlobalContext *Ctx) | 4620 TargetGlobalInitX8632::TargetGlobalInitX8632(GlobalContext *Ctx) |
4625 : TargetGlobalInitLowering(Ctx) {} | 4621 : TargetGlobalInitLowering(Ctx) {} |
4626 | 4622 |
4627 void TargetGlobalInitX8632::lower(const VariableDeclaration &Var) { | 4623 void TargetGlobalInitX8632::lower(const VariableDeclaration &Var) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4711 } else if (IsConstant || IsExternal) | 4707 } else if (IsConstant || IsExternal) |
4712 Str << "\t.zero\t" << Size << "\n"; | 4708 Str << "\t.zero\t" << Size << "\n"; |
4713 // Size is part of .comm. | 4709 // Size is part of .comm. |
4714 | 4710 |
4715 if (IsConstant || HasNonzeroInitializer || IsExternal) | 4711 if (IsConstant || HasNonzeroInitializer || IsExternal) |
4716 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; | 4712 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; |
4717 // Size is part of .comm. | 4713 // Size is part of .comm. |
4718 } | 4714 } |
4719 | 4715 |
4720 } // end of namespace Ice | 4716 } // end of namespace Ice |
OLD | NEW |