Chromium Code Reviews| Index: src/IceTargetLoweringARM32.h |
| diff --git a/src/IceTargetLoweringARM32.h b/src/IceTargetLoweringARM32.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..05913a74580e5bca88a955fb9b1cb59135d36a36 |
| --- /dev/null |
| +++ b/src/IceTargetLoweringARM32.h |
| @@ -0,0 +1,141 @@ |
| +//===- subzero/src/IceTargetLoweringARM32.h - ARM32 lowering ----*- C++ -*-===// |
| +// |
| +// The Subzero Code Generator |
| +// |
| +// This file is distributed under the University of Illinois Open Source |
| +// License. See LICENSE.TXT for details. |
| +// |
| +//===----------------------------------------------------------------------===// |
| +// |
| +// This file declares the TargetLoweringARM32 class, which implements the |
| +// TargetLowering interface for the ARM 32-bit architecture. |
| +// |
| +//===----------------------------------------------------------------------===// |
| + |
| +#ifndef SUBZERO_SRC_ICETARGETLOWERINGARM32_H |
| +#define SUBZERO_SRC_ICETARGETLOWERINGARM32_H |
| + |
| +#include "IceDefs.h" |
| +#include "IceRegistersARM32.h" |
| +#include "IceTargetLowering.h" |
| + |
| +namespace Ice { |
| + |
| +class TargetARM32 : public TargetLowering { |
| + TargetARM32() = delete; |
| + TargetARM32(const TargetARM32 &) = delete; |
| + TargetARM32 &operator=(const TargetARM32 &) = delete; |
| + |
| +public: |
| + static TargetARM32 *create(Cfg *Func) { return new TargetARM32(Func); } |
|
Jim Stichnoth
2015/04/17 19:16:02
Just noticed that TargetFoo::create() and TargetLo
jvoung (off chromium)
2015/04/21 17:05:30
Done.
|
| + |
| + void translateOm1() override; |
| + void translateO2() override; |
| + bool doBranchOpt(Inst *I, const CfgNode *NextNode) override; |
| + |
| + SizeT getNumRegisters() const override { return RegARM32::Reg_NUM; } |
| + Variable *getPhysicalRegister(SizeT RegNum, Type Ty = IceType_void) override; |
| + IceString getRegName(SizeT RegNum, Type Ty) const override; |
| + llvm::SmallBitVector getRegisterSet(RegSetMask Include, |
| + RegSetMask Exclude) const override; |
| + const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const override { |
| + return TypeToRegisterSet[Ty]; |
| + } |
| + bool hasFramePointer() const override { return UsesFramePointer; } |
| + SizeT getFrameOrStackReg() const override { |
| + return UsesFramePointer ? RegARM32::Reg_fp : RegARM32::Reg_sp; |
| + } |
| + size_t typeWidthInBytesOnStack(Type Ty) const override { |
| + // Round up to the next multiple of 4 bytes. In particular, i1, |
| + // i8, and i16 are rounded up to 4 bytes. |
| + return (typeWidthInBytes(Ty) + 3) & ~3; |
| + } |
| + void emitVariable(const Variable *Var) const override; |
| + void lowerArguments() override; |
| + void addProlog(CfgNode *Node) override; |
| + void addEpilog(CfgNode *Node) override; |
| + SizeT makeNextLabelNumber() { return NextLabelNumber++; } |
|
Jim Stichnoth
2015/04/17 19:16:01
Maybe this should be lifted into the base class?
jvoung (off chromium)
2015/04/21 17:05:30
Done.
|
| + |
| +protected: |
| + explicit TargetARM32(Cfg *Func); |
| + |
| + void postLower() override; |
| + |
| + void lowerAlloca(const InstAlloca *Inst) override; |
| + void lowerArithmetic(const InstArithmetic *Inst) override; |
| + void lowerAssign(const InstAssign *Inst) override; |
| + void lowerBr(const InstBr *Inst) override; |
| + void lowerCall(const InstCall *Inst) override; |
| + void lowerCast(const InstCast *Inst) override; |
| + void lowerExtractElement(const InstExtractElement *Inst) override; |
| + void lowerFcmp(const InstFcmp *Inst) override; |
| + void lowerIcmp(const InstIcmp *Inst) override; |
| + void lowerIntrinsicCall(const InstIntrinsicCall *Inst) override; |
| + void lowerInsertElement(const InstInsertElement *Inst) override; |
| + void lowerLoad(const InstLoad *Inst) override; |
| + void lowerPhi(const InstPhi *Inst) override; |
| + void lowerRet(const InstRet *Inst) override; |
| + void lowerSelect(const InstSelect *Inst) override; |
| + void lowerStore(const InstStore *Inst) override; |
| + void lowerSwitch(const InstSwitch *Inst) override; |
| + void lowerUnreachable(const InstUnreachable *Inst) override; |
| + void prelowerPhis() override; |
| + void lowerPhiAssignments(CfgNode *Node, |
| + const AssignList &Assignments) override; |
| + void doAddressOptLoad() override; |
| + void doAddressOptStore() override; |
| + void randomlyInsertNop(float Probability) override; |
| + void makeRandomRegisterPermutation( |
| + llvm::SmallVectorImpl<int32_t> &Permutation, |
| + const llvm::SmallBitVector &ExcludeRegisters) const override; |
| + |
| + // Make a call to an external helper function. |
| + // TODO(jvoung): Refactor to base TargetLowering? |
|
Jim Stichnoth
2015/04/17 19:16:02
sgtm
jvoung (off chromium)
2015/04/21 17:05:30
Went ahead and Done it.
|
| + InstCall *makeHelperCall(const IceString &Name, Variable *Dest, |
| + SizeT MaxSrcs) { |
| + const bool HasTailCall = false; |
| + Constant *CallTarget = Ctx->getConstantExternSym(Name); |
| + InstCall *Call = |
| + InstCall::create(Func, MaxSrcs, Dest, CallTarget, HasTailCall); |
| + return Call; |
| + } |
| + static Type stackSlotType(); |
| + |
| + bool UsesFramePointer; |
| + bool NeedsStackAlignment; |
| + llvm::SmallBitVector TypeToRegisterSet[IceType_NUM]; |
| + llvm::SmallBitVector ScratchRegs; |
| + llvm::SmallBitVector RegsUsed; |
| + SizeT NextLabelNumber; |
| + VarList PhysicalRegisters[IceType_NUM]; |
| + static IceString RegNames[]; |
| + |
| +private: |
| + ~TargetARM32() override {} |
| +}; |
| + |
| +class TargetDataARM32 : public TargetDataLowering { |
| + TargetDataARM32() = delete; |
| + TargetDataARM32(const TargetDataARM32 &) = delete; |
| + TargetDataARM32 &operator=(const TargetDataARM32 &) = delete; |
| + |
| +public: |
| + static TargetDataLowering *create(GlobalContext *Ctx) { |
| + return new TargetDataARM32(Ctx); |
| + } |
| + |
| + void lowerGlobals(std::unique_ptr<VariableDeclarationList> Vars) const final; |
| + void lowerConstants() const final; |
| + |
| +protected: |
| + explicit TargetDataARM32(GlobalContext *Ctx); |
| + |
| +private: |
| + void lowerGlobal(const VariableDeclaration &Var) const; |
| + ~TargetDataARM32() override {} |
| + template <typename T> static void emitConstantPool(GlobalContext *Ctx); |
| +}; |
| + |
| +} // end of namespace Ice |
| + |
| +#endif // SUBZERO_SRC_ICETARGETLOWERINGARM32_H |