| Index: src/IceTargetLoweringX86Base.h
|
| diff --git a/src/IceTargetLoweringX8632.h b/src/IceTargetLoweringX86Base.h
|
| similarity index 82%
|
| copy from src/IceTargetLoweringX8632.h
|
| copy to src/IceTargetLoweringX86Base.h
|
| index 6fce261f086b2fc9cd57e245803070e3bc4afb56..a7c4275afd1f5f82f6009cab2ec7084205ca96df 100644
|
| --- a/src/IceTargetLoweringX8632.h
|
| +++ b/src/IceTargetLoweringX86Base.h
|
| @@ -1,4 +1,4 @@
|
| -//===- subzero/src/IceTargetLoweringX8632.h - x86-32 lowering ---*- C++ -*-===//
|
| +//===- subzero/src/IceTargetLoweringX86Base.h - x86 lowering ----*- C++ -*-===//
|
| //
|
| // The Subzero Code Generator
|
| //
|
| @@ -7,96 +7,96 @@
|
| //
|
| //===----------------------------------------------------------------------===//
|
| //
|
| -// This file declares the TargetLoweringX8632 class, which
|
| -// implements the TargetLowering interface for the x86-32
|
| +// This file declares the TargetLoweringX86 template class, which
|
| +// implements the TargetLowering base interface for the x86
|
| // architecture.
|
| //
|
| //===----------------------------------------------------------------------===//
|
|
|
| -#ifndef SUBZERO_SRC_ICETARGETLOWERINGX8632_H
|
| -#define SUBZERO_SRC_ICETARGETLOWERINGX8632_H
|
| +#ifndef SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H
|
| +#define SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H
|
|
|
| #include <unordered_map>
|
|
|
| -#include "IceAssemblerX8632.h"
|
| #include "IceDefs.h"
|
| #include "IceInst.h"
|
| -#include "IceInstX8632.h"
|
| -#include "IceRegistersX8632.h"
|
| #include "IceTargetLowering.h"
|
|
|
| namespace Ice {
|
| +namespace X86Internal {
|
|
|
| -class BoolFoldingEntry {
|
| - BoolFoldingEntry(const BoolFoldingEntry &) = delete;
|
| +template <class MachineTraits> class BoolFolding;
|
|
|
| -public:
|
| - BoolFoldingEntry() = default;
|
| - explicit BoolFoldingEntry(Inst *I);
|
| - BoolFoldingEntry &operator=(const BoolFoldingEntry &) = default;
|
| - // Instr is the instruction producing the i1-type variable of interest.
|
| - Inst *Instr = nullptr;
|
| - // IsComplex is the cached result of BoolFolding::hasComplexLowering(Instr).
|
| - bool IsComplex = false;
|
| - // IsLiveOut is initialized conservatively to true, and is set to false when
|
| - // we encounter an instruction that ends Var's live range. We disable the
|
| - // folding optimization when Var is live beyond this basic block. Note that
|
| - // if liveness analysis is not performed (e.g. in Om1 mode), IsLiveOut will
|
| - // always be true and the folding optimization will never be performed.
|
| - bool IsLiveOut = true;
|
| - // NumUses counts the number of times Var is used as a source operand in the
|
| - // basic block. If IsComplex is true and there is more than one use of Var,
|
| - // then the folding optimization is disabled for Var.
|
| - uint32_t NumUses = 0;
|
| -};
|
| -
|
| -class BoolFolding {
|
| -public:
|
| - enum BoolFoldingProducerKind {
|
| - PK_None,
|
| - PK_Icmp32,
|
| - PK_Icmp64,
|
| - PK_Fcmp,
|
| - PK_Trunc
|
| - };
|
| -
|
| - // Currently the actual enum values are not used (other than CK_None), but we
|
| - // go
|
| - // ahead and produce them anyway for symmetry with the
|
| - // BoolFoldingProducerKind.
|
| - enum BoolFoldingConsumerKind { CK_None, CK_Br, CK_Select, CK_Sext, CK_Zext };
|
| -
|
| -private:
|
| - BoolFolding(const BoolFolding &) = delete;
|
| - BoolFolding &operator=(const BoolFolding &) = delete;
|
| -
|
| -public:
|
| - BoolFolding() = default;
|
| - static BoolFoldingProducerKind getProducerKind(const Inst *Instr);
|
| - static BoolFoldingConsumerKind getConsumerKind(const Inst *Instr);
|
| - static bool hasComplexLowering(const Inst *Instr);
|
| - void init(CfgNode *Node);
|
| - const Inst *getProducerFor(const Operand *Opnd) const;
|
| - void dump(const Cfg *Func) const;
|
| +template <class Machine> struct MachineTraits {};
|
|
|
| -private:
|
| - // Returns true if Producers contains a valid entry for the given VarNum.
|
| - bool containsValid(SizeT VarNum) const {
|
| - auto Element = Producers.find(VarNum);
|
| - return Element != Producers.end() && Element->second.Instr != nullptr;
|
| - }
|
| - void setInvalid(SizeT VarNum) { Producers[VarNum].Instr = nullptr; }
|
| - // Producers maps Variable::Number to a BoolFoldingEntry.
|
| - std::unordered_map<SizeT, BoolFoldingEntry> Producers;
|
| -};
|
| +template <class Machine> class TargetX86Base : public Machine {
|
| + TargetX86Base() = delete;
|
| + TargetX86Base(const TargetX86Base &) = delete;
|
| + TargetX86Base &operator=(const TargetX86Base &) = delete;
|
|
|
| -class TargetX8632 : public TargetLowering {
|
| - TargetX8632() = delete;
|
| - TargetX8632(const TargetX8632 &) = delete;
|
| - TargetX8632 &operator=(const TargetX8632 &) = delete;
|
| +protected:
|
| + using TargetLowering::H_bitcast_16xi1_i16;
|
| + using TargetLowering::H_bitcast_8xi1_i8;
|
| + using TargetLowering::H_bitcast_i16_16xi1;
|
| + using TargetLowering::H_bitcast_i8_8xi1;
|
| + using TargetLowering::H_call_ctpop_i32;
|
| + using TargetLowering::H_call_ctpop_i64;
|
| + using TargetLowering::H_call_longjmp;
|
| + using TargetLowering::H_call_memcpy;
|
| + using TargetLowering::H_call_memmove;
|
| + using TargetLowering::H_call_memset;
|
| + using TargetLowering::H_call_read_tp;
|
| + using TargetLowering::H_call_setjmp;
|
| + using TargetLowering::H_fptosi_f32_i64;
|
| + using TargetLowering::H_fptosi_f64_i64;
|
| + using TargetLowering::H_fptoui_4xi32_f32;
|
| + using TargetLowering::H_fptoui_f32_i32;
|
| + using TargetLowering::H_fptoui_f32_i64;
|
| + using TargetLowering::H_fptoui_f64_i32;
|
| + using TargetLowering::H_fptoui_f64_i64;
|
| + using TargetLowering::H_frem_f32;
|
| + using TargetLowering::H_frem_f64;
|
| + using TargetLowering::H_sdiv_i64;
|
| + using TargetLowering::H_sitofp_i64_f32;
|
| + using TargetLowering::H_sitofp_i64_f64;
|
| + using TargetLowering::H_srem_i64;
|
| + using TargetLowering::H_udiv_i64;
|
| + using TargetLowering::H_uitofp_4xi32_4xf32;
|
| + using TargetLowering::H_uitofp_i32_f32;
|
| + using TargetLowering::H_uitofp_i32_f64;
|
| + using TargetLowering::H_uitofp_i64_f32;
|
| + using TargetLowering::H_uitofp_i64_f64;
|
| + using TargetLowering::H_urem_i64;
|
| +
|
| + using TargetLowering::alignStackSpillAreas;
|
| + using TargetLowering::assignVarStackSlots;
|
| + using TargetLowering::inferTwoAddress;
|
| + using TargetLowering::makeHelperCall;
|
| + using TargetLowering::getVarStackSlotParams;
|
|
|
| public:
|
| - static TargetX8632 *create(Cfg *Func) { return new TargetX8632(Func); }
|
| + using Traits = MachineTraits<Machine>;
|
| + using BoolFolding = ::Ice::X86Internal::BoolFolding<Traits>;
|
| +
|
| + using TargetLowering::RegSet_All;
|
| + using TargetLowering::RegSet_CalleeSave;
|
| + using TargetLowering::RegSet_CallerSave;
|
| + using TargetLowering::RegSet_FramePointer;
|
| + using TargetLowering::RegSet_None;
|
| + using TargetLowering::RegSet_StackPointer;
|
| + using TargetLowering::Context;
|
| + using TargetLowering::Ctx;
|
| + using TargetLowering::Func;
|
| + using TargetLowering::RegSetMask;
|
| +
|
| + using TargetLowering::_bundle_lock;
|
| + using TargetLowering::_bundle_unlock;
|
| + using TargetLowering::getContext;
|
| + using TargetLowering::getStackAdjustment;
|
| + using TargetLowering::regAlloc;
|
| + using TargetLowering::resetStackAdjustment;
|
| +
|
| + static TargetX86Base *create(Cfg *Func) { return new TargetX86Base(Func); }
|
|
|
| void translateOm1() override;
|
| void translateO2() override;
|
| @@ -144,20 +144,14 @@ public:
|
| Operand *hiOperand(Operand *Operand);
|
| void finishArgumentLowering(Variable *Arg, Variable *FramePtr,
|
| size_t BasicFrameOffset, size_t &InArgsSizeBytes);
|
| - X8632::Address stackVarToAsmOperand(const Variable *Var) const;
|
| -
|
| - enum X86InstructionSet {
|
| - Begin,
|
| - // SSE2 is the PNaCl baseline instruction set.
|
| - SSE2 = Begin,
|
| - SSE4_1,
|
| - End
|
| - };
|
| + X8632::Address stackVarToAsmOperand(const Variable *Var) const final;
|
|
|
| - X86InstructionSet getInstructionSet() const { return InstructionSet; }
|
| + typename Traits::InstructionSet getInstructionSet() const final {
|
| + return InstructionSet;
|
| + }
|
|
|
| protected:
|
| - explicit TargetX8632(Cfg *Func);
|
| + explicit TargetX86Base(Cfg *Func);
|
|
|
| void postLower() override;
|
|
|
| @@ -199,7 +193,7 @@ protected:
|
| void lowerCountZeros(bool Cttz, Type Ty, Variable *Dest, Operand *FirstVal,
|
| Operand *SecondVal);
|
|
|
| - typedef void (TargetX8632::*LowerBinOp)(Variable *, Operand *);
|
| + typedef void (TargetX86Base::*LowerBinOp)(Variable *, Operand *);
|
| void expandAtomicRMWAsCmpxchg(LowerBinOp op_lo, LowerBinOp op_hi,
|
| Variable *Dest, Operand *Ptr, Operand *Val);
|
|
|
| @@ -585,7 +579,8 @@ protected:
|
| bool optimizeScalarMul(Variable *Dest, Operand *Src0, int32_t Src1);
|
| void findRMW();
|
|
|
| - X86InstructionSet InstructionSet = X86InstructionSet::Begin;
|
| + typename Traits::InstructionSet InstructionSet =
|
| + Traits::InstructionSet::Begin;
|
| bool IsEbpBasedFrame = false;
|
| bool NeedsStackAlignment = false;
|
| size_t SpillAreaSizeBytes = 0;
|
| @@ -604,49 +599,12 @@ protected:
|
| bool RandomizationPoolingPaused = false;
|
|
|
| private:
|
| - ~TargetX8632() override {}
|
| + ~TargetX86Base() override {}
|
| BoolFolding FoldingInfo;
|
| };
|
| -
|
| -class TargetDataX8632 final : public TargetDataLowering {
|
| - TargetDataX8632() = delete;
|
| - TargetDataX8632(const TargetDataX8632 &) = delete;
|
| - TargetDataX8632 &operator=(const TargetDataX8632 &) = delete;
|
| -
|
| -public:
|
| - static std::unique_ptr<TargetDataLowering> create(GlobalContext *Ctx) {
|
| - return std::unique_ptr<TargetDataLowering>(new TargetDataX8632(Ctx));
|
| - }
|
| -
|
| - void lowerGlobals(const VariableDeclarationList &Vars,
|
| - const IceString &SectionSuffix) override;
|
| - void lowerConstants() override;
|
| -
|
| -protected:
|
| - explicit TargetDataX8632(GlobalContext *Ctx);
|
| -
|
| -private:
|
| - ~TargetDataX8632() override {}
|
| - template <typename T> static void emitConstantPool(GlobalContext *Ctx);
|
| -};
|
| -
|
| -class TargetHeaderX8632 final : public TargetHeaderLowering {
|
| - TargetHeaderX8632() = delete;
|
| - TargetHeaderX8632(const TargetHeaderX8632 &) = delete;
|
| - TargetHeaderX8632 &operator=(const TargetHeaderX8632 &) = delete;
|
| -
|
| -public:
|
| - static std::unique_ptr<TargetHeaderLowering> create(GlobalContext *Ctx) {
|
| - return std::unique_ptr<TargetHeaderLowering>(new TargetHeaderX8632(Ctx));
|
| - }
|
| -
|
| -protected:
|
| - explicit TargetHeaderX8632(GlobalContext *Ctx);
|
| -
|
| -private:
|
| - ~TargetHeaderX8632() = default;
|
| -};
|
| -
|
| +} // end of namespace X86Internal
|
| } // end of namespace Ice
|
|
|
| -#endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H
|
| +#include "IceTargetLoweringX86BaseImpl.h"
|
| +
|
| +#endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASE_H
|
|
|