blob: 61878090ca70ea3ce2866f8c5bf823e9df03205e [file] [log] [blame]
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -07001//===- subzero/src/IceTargetLoweringX8632.h - x86-32 lowering ---*- C++ -*-===//
2//
3// The Subzero Code Generator
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Andrew Scull9612d322015-07-06 14:53:25 -07009///
10/// \file
11/// This file declares the TargetLoweringX8632 class, which
12/// implements the TargetLowering interface for the x86-32
13/// architecture.
14///
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070015//===----------------------------------------------------------------------===//
16
17#ifndef SUBZERO_SRC_ICETARGETLOWERINGX8632_H
18#define SUBZERO_SRC_ICETARGETLOWERINGX8632_H
19
John Portoaff4ccf2015-06-10 16:35:06 -070020#include "IceAssemblerX8632.h"
Jim Stichnotha18cc9c2014-09-30 19:10:22 -070021#include "IceDefs.h"
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070022#include "IceInstX8632.h"
Jan Voungbd385e42014-09-18 18:18:10 -070023#include "IceRegistersX8632.h"
Jim Stichnotha18cc9c2014-09-30 19:10:22 -070024#include "IceTargetLowering.h"
John Porto5d0acff2015-06-30 15:29:21 -070025#include "IceTargetLoweringX8632Traits.h"
John Porto5aeed952015-07-21 13:39:09 -070026#include "IceTargetLoweringX86Base.h"
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070027
28namespace Ice {
29
John Porto5aeed952015-07-21 13:39:09 -070030class TargetX8632 final
31 : public ::Ice::X86Internal::TargetX86Base<TargetX8632> {
Jim Stichnothc6ead202015-02-24 09:30:30 -080032 TargetX8632() = delete;
Jim Stichnoth7b451a92014-10-15 14:39:23 -070033 TargetX8632(const TargetX8632 &) = delete;
34 TargetX8632 &operator=(const TargetX8632 &) = delete;
35
Andrew Scull86df4e92015-07-30 13:54:44 -070036 void emitJumpTable(const Cfg *Func,
37 const InstJumpTable *JumpTable) const override;
38
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070039public:
John Porto5d0acff2015-06-30 15:29:21 -070040 using X86InstructionSet = X8632::Traits::InstructionSet;
Matt Wala0a450512014-07-30 12:44:39 -070041
John Porto5aeed952015-07-21 13:39:09 -070042 static TargetX8632 *create(Cfg *Func) { return new TargetX8632(Func); }
Matt Wala0a450512014-07-30 12:44:39 -070043
John Portoe0d9afa2015-08-05 10:13:44 -070044protected:
45 void lowerCall(const InstCall *Instr) override;
John Porto729b5f62015-08-06 07:44:30 -070046 void lowerArguments() override;
47 void lowerRet(const InstRet *Inst) override;
48 void addProlog(CfgNode *Node) override;
49 void addEpilog(CfgNode *Node) override;
John Portoe0d9afa2015-08-05 10:13:44 -070050
John Porto453660f2015-07-31 14:52:52 -070051private:
52 friend class ::Ice::X86Internal::TargetX86Base<TargetX8632>;
53
John Porto5aeed952015-07-21 13:39:09 -070054 Operand *createNaClReadTPSrcOperand() {
55 Constant *Zero = Ctx->getConstantZero(IceType_i32);
56 return Traits::X86OperandMem::create(Func, IceType_i32, nullptr, Zero,
57 nullptr, 0,
58 Traits::X86OperandMem::SegReg_GS);
59 }
60
John Porto5aeed952015-07-21 13:39:09 -070061 explicit TargetX8632(Cfg *Func) : TargetX86Base(Func) {}
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070062};
63
John Porto0f86d032015-06-15 07:44:27 -070064class TargetDataX8632 final : public TargetDataLowering {
Jan Voung72984d82015-01-29 14:42:38 -080065 TargetDataX8632() = delete;
66 TargetDataX8632(const TargetDataX8632 &) = delete;
67 TargetDataX8632 &operator=(const TargetDataX8632 &) = delete;
Jim Stichnoth7b451a92014-10-15 14:39:23 -070068
Jim Stichnothde4ca712014-06-29 08:13:48 -070069public:
John Porto453660f2015-07-31 14:52:52 -070070 ~TargetDataX8632() override = default;
71
Jan Voungfb792842015-06-11 15:27:50 -070072 static std::unique_ptr<TargetDataLowering> create(GlobalContext *Ctx) {
John Porto453660f2015-07-31 14:52:52 -070073 return makeUnique<TargetDataX8632>(Ctx);
Jim Stichnothde4ca712014-06-29 08:13:48 -070074 }
Karl Schimpfe3f64d02014-10-07 10:38:22 -070075
John Porto8b1a7052015-06-17 13:20:08 -070076 void lowerGlobals(const VariableDeclarationList &Vars,
77 const IceString &SectionSuffix) override;
John Porto0f86d032015-06-15 07:44:27 -070078 void lowerConstants() override;
Andrew Scull86df4e92015-07-30 13:54:44 -070079 void lowerJumpTables() override;
Jim Stichnothde4ca712014-06-29 08:13:48 -070080
Jim Stichnothde4ca712014-06-29 08:13:48 -070081private:
John Porto453660f2015-07-31 14:52:52 -070082 ENABLE_MAKE_UNIQUE;
83
84 explicit TargetDataX8632(GlobalContext *Ctx);
Jim Stichnothfa4efea2015-01-27 05:06:03 -080085 template <typename T> static void emitConstantPool(GlobalContext *Ctx);
Jim Stichnothde4ca712014-06-29 08:13:48 -070086};
87
Jan Voungfb792842015-06-11 15:27:50 -070088class TargetHeaderX8632 final : public TargetHeaderLowering {
89 TargetHeaderX8632() = delete;
90 TargetHeaderX8632(const TargetHeaderX8632 &) = delete;
91 TargetHeaderX8632 &operator=(const TargetHeaderX8632 &) = delete;
92
93public:
94 static std::unique_ptr<TargetHeaderLowering> create(GlobalContext *Ctx) {
95 return std::unique_ptr<TargetHeaderLowering>(new TargetHeaderX8632(Ctx));
96 }
97
98protected:
99 explicit TargetHeaderX8632(GlobalContext *Ctx);
100
101private:
102 ~TargetHeaderX8632() = default;
103};
104
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700105} // end of namespace Ice
106
107#endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H