blob: 1f1d2cb0a2555507fc692c408b6044a93d40c8e4 [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
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070036public:
John Porto5d0acff2015-06-30 15:29:21 -070037 using X86InstructionSet = X8632::Traits::InstructionSet;
Matt Wala0a450512014-07-30 12:44:39 -070038
John Porto5aeed952015-07-21 13:39:09 -070039 static TargetX8632 *create(Cfg *Func) { return new TargetX8632(Func); }
Matt Wala0a450512014-07-30 12:44:39 -070040
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070041protected:
John Porto5aeed952015-07-21 13:39:09 -070042 Operand *createNaClReadTPSrcOperand() {
43 Constant *Zero = Ctx->getConstantZero(IceType_i32);
44 return Traits::X86OperandMem::create(Func, IceType_i32, nullptr, Zero,
45 nullptr, 0,
46 Traits::X86OperandMem::SegReg_GS);
47 }
48
49private:
50 friend class ::Ice::X86Internal::TargetX86Base<TargetX8632>;
51
52 explicit TargetX8632(Cfg *Func) : TargetX86Base(Func) {}
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070053};
54
John Porto0f86d032015-06-15 07:44:27 -070055class TargetDataX8632 final : public TargetDataLowering {
Jan Voung72984d82015-01-29 14:42:38 -080056 TargetDataX8632() = delete;
57 TargetDataX8632(const TargetDataX8632 &) = delete;
58 TargetDataX8632 &operator=(const TargetDataX8632 &) = delete;
Jim Stichnoth7b451a92014-10-15 14:39:23 -070059
Jim Stichnothde4ca712014-06-29 08:13:48 -070060public:
Jan Voungfb792842015-06-11 15:27:50 -070061 static std::unique_ptr<TargetDataLowering> create(GlobalContext *Ctx) {
62 return std::unique_ptr<TargetDataLowering>(new TargetDataX8632(Ctx));
Jim Stichnothde4ca712014-06-29 08:13:48 -070063 }
Karl Schimpfe3f64d02014-10-07 10:38:22 -070064
John Porto8b1a7052015-06-17 13:20:08 -070065 void lowerGlobals(const VariableDeclarationList &Vars,
66 const IceString &SectionSuffix) override;
John Porto0f86d032015-06-15 07:44:27 -070067 void lowerConstants() override;
Jim Stichnothde4ca712014-06-29 08:13:48 -070068
69protected:
Jim Stichnothc6ead202015-02-24 09:30:30 -080070 explicit TargetDataX8632(GlobalContext *Ctx);
Jim Stichnothde4ca712014-06-29 08:13:48 -070071
72private:
John Porto7e93c622015-06-23 10:58:57 -070073 ~TargetDataX8632() override = default;
Jim Stichnothfa4efea2015-01-27 05:06:03 -080074 template <typename T> static void emitConstantPool(GlobalContext *Ctx);
Jim Stichnothde4ca712014-06-29 08:13:48 -070075};
76
Jan Voungfb792842015-06-11 15:27:50 -070077class TargetHeaderX8632 final : public TargetHeaderLowering {
78 TargetHeaderX8632() = delete;
79 TargetHeaderX8632(const TargetHeaderX8632 &) = delete;
80 TargetHeaderX8632 &operator=(const TargetHeaderX8632 &) = delete;
81
82public:
83 static std::unique_ptr<TargetHeaderLowering> create(GlobalContext *Ctx) {
84 return std::unique_ptr<TargetHeaderLowering>(new TargetHeaderX8632(Ctx));
85 }
86
87protected:
88 explicit TargetHeaderX8632(GlobalContext *Ctx);
89
90private:
91 ~TargetHeaderX8632() = default;
92};
93
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070094} // end of namespace Ice
95
96#endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H