blob: 8c4329d77758d27aa82f8b89b1e10aa44bf5e3a3 [file] [log] [blame]
John Portod58f01c2015-06-23 15:55:17 -07001//===- subzero/src/IceTargetLoweringX8664.h - lowering for x86-64 -*- C++ -*-=//
John Porto7e93c622015-06-23 10:58:57 -07002//
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 TargetLoweringX8664 class, which implements the
12/// TargetLowering interface for the X86 64-bit architecture.
13///
John Porto7e93c622015-06-23 10:58:57 -070014//===----------------------------------------------------------------------===//
John Portod58f01c2015-06-23 15:55:17 -070015
John Porto7e93c622015-06-23 10:58:57 -070016#ifndef SUBZERO_SRC_ICETARGETLOWERINGX8664_H
17#define SUBZERO_SRC_ICETARGETLOWERINGX8664_H
18
John Porto453660f2015-07-31 14:52:52 -070019#include "IceAssemblerX8664.h"
John Portod58f01c2015-06-23 15:55:17 -070020#include "IceCfg.h"
21#include "IceGlobalContext.h"
John Porto453660f2015-07-31 14:52:52 -070022#include "IceInstX8664.h"
John Porto7e93c622015-06-23 10:58:57 -070023#include "IceTargetLowering.h"
John Porto453660f2015-07-31 14:52:52 -070024#include "IceTargetLoweringX8664Traits.h"
25#include "IceTargetLoweringX86Base.h"
John Porto7e93c622015-06-23 10:58:57 -070026
27namespace Ice {
28
John Porto453660f2015-07-31 14:52:52 -070029class TargetX8664 final
30 : public ::Ice::X86Internal::TargetX86Base<TargetX8664> {
John Porto7e93c622015-06-23 10:58:57 -070031 TargetX8664() = delete;
32 TargetX8664(const TargetX8664 &) = delete;
33 TargetX8664 &operator=(const TargetX8664 &) = delete;
34
Andrew Scull86df4e92015-07-30 13:54:44 -070035 void emitJumpTable(const Cfg *Func,
36 const InstJumpTable *JumpTable) const override;
37
John Porto7e93c622015-06-23 10:58:57 -070038public:
John Porto453660f2015-07-31 14:52:52 -070039 static TargetX8664 *create(Cfg *Func) { return new TargetX8664(Func); }
John Portod58f01c2015-06-23 15:55:17 -070040
41private:
John Porto453660f2015-07-31 14:52:52 -070042 friend class ::Ice::X86Internal::TargetX86Base<TargetX8664>;
43
44 explicit TargetX8664(Cfg *Func)
45 : ::Ice::X86Internal::TargetX86Base<TargetX8664>(Func) {}
46
47 Operand *createNaClReadTPSrcOperand() {
48 Variable *TDB = makeReg(IceType_i32);
49 InstCall *Call = makeHelperCall(H_call_read_tp, TDB, 0);
50 lowerCall(Call);
51 return TDB;
52 }
John Porto7e93c622015-06-23 10:58:57 -070053};
54
55class TargetDataX8664 : public TargetDataLowering {
56 TargetDataX8664() = delete;
57 TargetDataX8664(const TargetDataX8664 &) = delete;
58 TargetDataX8664 &operator=(const TargetDataX8664 &) = delete;
59
60public:
John Portod58f01c2015-06-23 15:55:17 -070061 ~TargetDataX8664() override = default;
62
John Porto7e93c622015-06-23 10:58:57 -070063 static std::unique_ptr<TargetDataLowering> create(GlobalContext *Ctx) {
John Portod58f01c2015-06-23 15:55:17 -070064 return makeUnique<TargetDataX8664>(Ctx);
John Porto7e93c622015-06-23 10:58:57 -070065 }
John Portod58f01c2015-06-23 15:55:17 -070066
67 void lowerGlobals(const VariableDeclarationList &Vars,
68 const IceString &SectionSuffix) override;
69
70 void lowerConstants() override;
Andrew Scull86df4e92015-07-30 13:54:44 -070071 void lowerJumpTables() override;
John Portod58f01c2015-06-23 15:55:17 -070072
73private:
74 ENABLE_MAKE_UNIQUE;
75
76 explicit TargetDataX8664(GlobalContext *Ctx) : TargetDataLowering(Ctx) {}
John Porto453660f2015-07-31 14:52:52 -070077 template <typename T> static void emitConstantPool(GlobalContext *Ctx);
John Porto7e93c622015-06-23 10:58:57 -070078};
79
80class TargetHeaderX8664 : public TargetHeaderLowering {
81 TargetHeaderX8664() = delete;
82 TargetHeaderX8664(const TargetHeaderX8664 &) = delete;
83 TargetHeaderX8664 &operator=(const TargetHeaderX8664 &) = delete;
84
85public:
John Portod58f01c2015-06-23 15:55:17 -070086 ~TargetHeaderX8664() = default;
John Porto7e93c622015-06-23 10:58:57 -070087
John Portod58f01c2015-06-23 15:55:17 -070088 static std::unique_ptr<TargetHeaderLowering> create(GlobalContext *Ctx) {
89 return makeUnique<TargetHeaderX8664>(Ctx);
90 }
91
92private:
93 ENABLE_MAKE_UNIQUE;
94
95 explicit TargetHeaderX8664(GlobalContext *Ctx) : TargetHeaderLowering(Ctx) {}
96};
John Porto7e93c622015-06-23 10:58:57 -070097} // end of namespace Ice
98
Jim Stichnoth20b71f52015-06-24 15:52:24 -070099#endif // SUBZERO_SRC_ICETARGETLOWERINGX8664_H