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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 TypeToRegisterSet[IceType_v16i1] = VectorRegisters; | 306 TypeToRegisterSet[IceType_v16i1] = VectorRegisters; |
307 TypeToRegisterSet[IceType_v16i8] = VectorRegisters; | 307 TypeToRegisterSet[IceType_v16i8] = VectorRegisters; |
308 TypeToRegisterSet[IceType_v8i16] = VectorRegisters; | 308 TypeToRegisterSet[IceType_v8i16] = VectorRegisters; |
309 TypeToRegisterSet[IceType_v4i32] = VectorRegisters; | 309 TypeToRegisterSet[IceType_v4i32] = VectorRegisters; |
310 TypeToRegisterSet[IceType_v4f32] = VectorRegisters; | 310 TypeToRegisterSet[IceType_v4f32] = VectorRegisters; |
311 } | 311 } |
312 | 312 |
313 void TargetX8632::translateO2() { | 313 void TargetX8632::translateO2() { |
314 TimerMarker T(TimerStack::TT_O2, Func); | 314 TimerMarker T(TimerStack::TT_O2, Func); |
315 | 315 |
316 if (!Ctx->getFlags().PhiEdgeSplit) { | 316 if (!Ctx->getFlags().getPhiEdgeSplit()) { |
317 // Lower Phi instructions. | 317 // Lower Phi instructions. |
318 Func->placePhiLoads(); | 318 Func->placePhiLoads(); |
319 if (Func->hasError()) | 319 if (Func->hasError()) |
320 return; | 320 return; |
321 Func->placePhiStores(); | 321 Func->placePhiStores(); |
322 if (Func->hasError()) | 322 if (Func->hasError()) |
323 return; | 323 return; |
324 Func->deletePhis(); | 324 Func->deletePhis(); |
325 if (Func->hasError()) | 325 if (Func->hasError()) |
326 return; | 326 return; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 assert(Func->validateLiveness()); | 370 assert(Func->validateLiveness()); |
371 // The post-codegen dump is done here, after liveness analysis and | 371 // The post-codegen dump is done here, after liveness analysis and |
372 // associated cleanup, to make the dump cleaner and more useful. | 372 // associated cleanup, to make the dump cleaner and more useful. |
373 Func->dump("After initial x8632 codegen"); | 373 Func->dump("After initial x8632 codegen"); |
374 Func->getVMetadata()->init(VMK_All); | 374 Func->getVMetadata()->init(VMK_All); |
375 regAlloc(RAK_Global); | 375 regAlloc(RAK_Global); |
376 if (Func->hasError()) | 376 if (Func->hasError()) |
377 return; | 377 return; |
378 Func->dump("After linear scan regalloc"); | 378 Func->dump("After linear scan regalloc"); |
379 | 379 |
380 if (Ctx->getFlags().PhiEdgeSplit) { | 380 if (Ctx->getFlags().getPhiEdgeSplit()) { |
381 Func->advancedPhiLowering(); | 381 Func->advancedPhiLowering(); |
382 Func->dump("After advanced Phi lowering"); | 382 Func->dump("After advanced Phi lowering"); |
383 } | 383 } |
384 | 384 |
385 // Stack frame mapping. | 385 // Stack frame mapping. |
386 Func->genFrame(); | 386 Func->genFrame(); |
387 if (Func->hasError()) | 387 if (Func->hasError()) |
388 return; | 388 return; |
389 Func->dump("After stack frame mapping"); | 389 Func->dump("After stack frame mapping"); |
390 | 390 |
(...skipping 2669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3060 Variable *ValExt = Func->makeVariable(stackSlotType()); | 3060 Variable *ValExt = Func->makeVariable(stackSlotType()); |
3061 lowerCast(InstCast::create(Func, InstCast::Zext, ValExt, ValOp)); | 3061 lowerCast(InstCast::create(Func, InstCast::Zext, ValExt, ValOp)); |
3062 InstCall *Call = makeHelperCall("memset", nullptr, 3); | 3062 InstCall *Call = makeHelperCall("memset", nullptr, 3); |
3063 Call->addArg(Instr->getArg(0)); | 3063 Call->addArg(Instr->getArg(0)); |
3064 Call->addArg(ValExt); | 3064 Call->addArg(ValExt); |
3065 Call->addArg(Instr->getArg(2)); | 3065 Call->addArg(Instr->getArg(2)); |
3066 lowerCall(Call); | 3066 lowerCall(Call); |
3067 return; | 3067 return; |
3068 } | 3068 } |
3069 case Intrinsics::NaClReadTP: { | 3069 case Intrinsics::NaClReadTP: { |
3070 if (Ctx->getFlags().UseSandboxing) { | 3070 if (Ctx->getFlags().getUseSandboxing()) { |
3071 Constant *Zero = Ctx->getConstantZero(IceType_i32); | 3071 Constant *Zero = Ctx->getConstantZero(IceType_i32); |
3072 Operand *Src = | 3072 Operand *Src = |
3073 OperandX8632Mem::create(Func, IceType_i32, nullptr, Zero, nullptr, 0, | 3073 OperandX8632Mem::create(Func, IceType_i32, nullptr, Zero, nullptr, 0, |
3074 OperandX8632Mem::SegReg_GS); | 3074 OperandX8632Mem::SegReg_GS); |
3075 Variable *Dest = Instr->getDest(); | 3075 Variable *Dest = Instr->getDest(); |
3076 Variable *T = nullptr; | 3076 Variable *T = nullptr; |
3077 _mov(T, Src); | 3077 _mov(T, Src); |
3078 _mov(Dest, T); | 3078 _mov(Dest, T); |
3079 } else { | 3079 } else { |
3080 InstCall *Call = makeHelperCall("__nacl_read_tp", Instr->getDest(), 0); | 3080 InstCall *Call = makeHelperCall("__nacl_read_tp", Instr->getDest(), 0); |
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4559 void ConstantUndef::emit(GlobalContext *) const { | 4559 void ConstantUndef::emit(GlobalContext *) const { |
4560 llvm_unreachable("undef value encountered by emitter."); | 4560 llvm_unreachable("undef value encountered by emitter."); |
4561 } | 4561 } |
4562 | 4562 |
4563 TargetDataX8632::TargetDataX8632(GlobalContext *Ctx) | 4563 TargetDataX8632::TargetDataX8632(GlobalContext *Ctx) |
4564 : TargetDataLowering(Ctx) {} | 4564 : TargetDataLowering(Ctx) {} |
4565 | 4565 |
4566 void TargetDataX8632::lowerGlobal(const VariableDeclaration &Var) const { | 4566 void TargetDataX8632::lowerGlobal(const VariableDeclaration &Var) const { |
4567 // If external and not initialized, this must be a cross test. | 4567 // If external and not initialized, this must be a cross test. |
4568 // Don't generate a declaration for such cases. | 4568 // Don't generate a declaration for such cases. |
4569 bool IsExternal = Var.isExternal() || Ctx->getFlags().DisableInternal; | 4569 bool IsExternal = Var.isExternal() || Ctx->getFlags().getDisableInternal(); |
4570 if (IsExternal && !Var.hasInitializer()) | 4570 if (IsExternal && !Var.hasInitializer()) |
4571 return; | 4571 return; |
4572 | 4572 |
4573 Ostream &Str = Ctx->getStrEmit(); | 4573 Ostream &Str = Ctx->getStrEmit(); |
4574 const VariableDeclaration::InitializerListType &Initializers = | 4574 const VariableDeclaration::InitializerListType &Initializers = |
4575 Var.getInitializers(); | 4575 Var.getInitializers(); |
4576 bool HasNonzeroInitializer = Var.hasNonzeroInitializer(); | 4576 bool HasNonzeroInitializer = Var.hasNonzeroInitializer(); |
4577 bool IsConstant = Var.getIsConstant(); | 4577 bool IsConstant = Var.getIsConstant(); |
4578 uint32_t Align = Var.getAlignment(); | 4578 uint32_t Align = Var.getAlignment(); |
4579 SizeT Size = Var.getNumBytes(); | 4579 SizeT Size = Var.getNumBytes(); |
4580 IceString MangledName = Var.mangleName(Ctx); | 4580 IceString MangledName = Var.mangleName(Ctx); |
4581 IceString SectionSuffix = ""; | 4581 IceString SectionSuffix = ""; |
4582 if (Ctx->getFlags().DataSections) | 4582 if (Ctx->getFlags().getDataSections()) |
4583 SectionSuffix = "." + MangledName; | 4583 SectionSuffix = "." + MangledName; |
4584 | 4584 |
4585 Str << "\t.type\t" << MangledName << ",@object\n"; | 4585 Str << "\t.type\t" << MangledName << ",@object\n"; |
4586 | 4586 |
4587 if (IsConstant) | 4587 if (IsConstant) |
4588 Str << "\t.section\t.rodata" << SectionSuffix << ",\"a\",@progbits\n"; | 4588 Str << "\t.section\t.rodata" << SectionSuffix << ",\"a\",@progbits\n"; |
4589 else if (HasNonzeroInitializer) | 4589 else if (HasNonzeroInitializer) |
4590 Str << "\t.section\t.data" << SectionSuffix << ",\"aw\",@progbits\n"; | 4590 Str << "\t.section\t.data" << SectionSuffix << ",\"aw\",@progbits\n"; |
4591 else | 4591 else |
4592 Str << "\t.section\t.bss" << SectionSuffix << ",\"aw\",@nobits\n"; | 4592 Str << "\t.section\t.bss" << SectionSuffix << ",\"aw\",@nobits\n"; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4695 assert(CharsPrinted >= 0 && | 4695 assert(CharsPrinted >= 0 && |
4696 (size_t)CharsPrinted < llvm::array_lengthof(buf)); | 4696 (size_t)CharsPrinted < llvm::array_lengthof(buf)); |
4697 (void)CharsPrinted; // avoid warnings if asserts are disabled | 4697 (void)CharsPrinted; // avoid warnings if asserts are disabled |
4698 Const->emitPoolLabel(Str); | 4698 Const->emitPoolLabel(Str); |
4699 Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t# " << T::TypeName << " " | 4699 Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t# " << T::TypeName << " " |
4700 << Value << "\n"; | 4700 << Value << "\n"; |
4701 } | 4701 } |
4702 } | 4702 } |
4703 | 4703 |
4704 void TargetDataX8632::lowerConstants(GlobalContext *Ctx) const { | 4704 void TargetDataX8632::lowerConstants(GlobalContext *Ctx) const { |
4705 if (Ctx->getFlags().DisableTranslation) | 4705 if (Ctx->getFlags().getDisableTranslation()) |
4706 return; | 4706 return; |
4707 // No need to emit constants from the int pool since (for x86) they | 4707 // No need to emit constants from the int pool since (for x86) they |
4708 // are embedded as immediates in the instructions, just emit float/double. | 4708 // are embedded as immediates in the instructions, just emit float/double. |
4709 if (Ctx->getFlags().UseELFWriter) { | 4709 if (Ctx->getFlags().getUseELFWriter()) { |
4710 ELFObjectWriter *Writer = Ctx->getObjectWriter(); | 4710 ELFObjectWriter *Writer = Ctx->getObjectWriter(); |
4711 Writer->writeConstantPool<ConstantFloat>(IceType_f32); | 4711 Writer->writeConstantPool<ConstantFloat>(IceType_f32); |
4712 Writer->writeConstantPool<ConstantDouble>(IceType_f64); | 4712 Writer->writeConstantPool<ConstantDouble>(IceType_f64); |
4713 } else { | 4713 } else { |
4714 OstreamLocker L(Ctx); | 4714 OstreamLocker L(Ctx); |
4715 emitConstantPool<PoolTypeConverter<float>>(Ctx); | 4715 emitConstantPool<PoolTypeConverter<float>>(Ctx); |
4716 emitConstantPool<PoolTypeConverter<double>>(Ctx); | 4716 emitConstantPool<PoolTypeConverter<double>>(Ctx); |
4717 } | 4717 } |
4718 } | 4718 } |
4719 | 4719 |
4720 } // end of namespace Ice | 4720 } // end of namespace Ice |
OLD | NEW |