Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: src/IceTargetLoweringX8632.h

Issue 582113003: Lift register and condition code enums out into their own file. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: add first and last Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceRegistersX8632.h ('k') | src/IceTargetLoweringX8632.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLoweringX8632.h - x86-32 lowering ---*- C++ -*-===// 1 //===- subzero/src/IceTargetLoweringX8632.h - x86-32 lowering ---*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file declares the TargetLoweringX8632 class, which 10 // This file declares the TargetLoweringX8632 class, which
11 // implements the TargetLowering interface for the x86-32 11 // implements the TargetLowering interface for the x86-32
12 // architecture. 12 // architecture.
13 // 13 //
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #ifndef SUBZERO_SRC_ICETARGETLOWERINGX8632_H 16 #ifndef SUBZERO_SRC_ICETARGETLOWERINGX8632_H
17 #define SUBZERO_SRC_ICETARGETLOWERINGX8632_H 17 #define SUBZERO_SRC_ICETARGETLOWERINGX8632_H
18 18
19 #include "IceDefs.h" 19 #include "IceDefs.h"
20 #include "IceTargetLowering.h" 20 #include "IceTargetLowering.h"
21 #include "IceInstX8632.h" 21 #include "IceInstX8632.h"
22 #include "IceRegistersX8632.h"
22 23
23 namespace Ice { 24 namespace Ice {
24 25
25 class TargetX8632 : public TargetLowering { 26 class TargetX8632 : public TargetLowering {
26 public: 27 public:
27 static TargetX8632 *create(Cfg *Func) { return new TargetX8632(Func); } 28 static TargetX8632 *create(Cfg *Func) { return new TargetX8632(Func); }
28 29
29 virtual void translateOm1(); 30 virtual void translateOm1();
30 virtual void translateO2(); 31 virtual void translateO2();
31 virtual bool doBranchOpt(Inst *I, const CfgNode *NextNode); 32 virtual bool doBranchOpt(Inst *I, const CfgNode *NextNode);
32 33
33 virtual Variable *getPhysicalRegister(SizeT RegNum); 34 virtual Variable *getPhysicalRegister(SizeT RegNum);
34 virtual IceString getRegName(SizeT RegNum, Type Ty) const; 35 virtual IceString getRegName(SizeT RegNum, Type Ty) const;
35 virtual llvm::SmallBitVector getRegisterSet(RegSetMask Include, 36 virtual llvm::SmallBitVector getRegisterSet(RegSetMask Include,
36 RegSetMask Exclude) const; 37 RegSetMask Exclude) const;
37 virtual const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const { 38 virtual const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const {
38 return TypeToRegisterSet[Ty]; 39 return TypeToRegisterSet[Ty];
39 } 40 }
40 virtual bool hasFramePointer() const { return IsEbpBasedFrame; } 41 virtual bool hasFramePointer() const { return IsEbpBasedFrame; }
41 virtual SizeT getFrameOrStackReg() const { 42 virtual SizeT getFrameOrStackReg() const {
42 return IsEbpBasedFrame ? Reg_ebp : Reg_esp; 43 return IsEbpBasedFrame ? RegX8632::Reg_ebp : RegX8632::Reg_esp;
43 } 44 }
44 virtual size_t typeWidthInBytesOnStack(Type Ty) const { 45 virtual size_t typeWidthInBytesOnStack(Type Ty) const {
45 // Round up to the next multiple of 4 bytes. In particular, i1, 46 // Round up to the next multiple of 4 bytes. In particular, i1,
46 // i8, and i16 are rounded up to 4 bytes. 47 // i8, and i16 are rounded up to 4 bytes.
47 return (typeWidthInBytes(Ty) + 3) & ~3; 48 return (typeWidthInBytes(Ty) + 3) & ~3;
48 } 49 }
49 virtual SizeT getBundleAlignLog2Bytes() const { return 5; } 50 virtual SizeT getBundleAlignLog2Bytes() const { return 5; }
50 virtual llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const { 51 virtual llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const {
51 static const uint8_t Padding[] = { 0xF4 }; 52 static const uint8_t Padding[] = { 0xF4 };
52 return llvm::ArrayRef<uint8_t>(Padding, 1); 53 return llvm::ArrayRef<uint8_t>(Padding, 1);
53 } 54 }
54 virtual void emitVariable(const Variable *Var, const Cfg *Func) const; 55 virtual void emitVariable(const Variable *Var, const Cfg *Func) const;
55 virtual void lowerArguments(); 56 virtual void lowerArguments();
56 virtual void addProlog(CfgNode *Node); 57 virtual void addProlog(CfgNode *Node);
57 virtual void addEpilog(CfgNode *Node); 58 virtual void addEpilog(CfgNode *Node);
58 virtual void emitConstants() const; 59 virtual void emitConstants() const;
59 SizeT makeNextLabelNumber() { return NextLabelNumber++; } 60 SizeT makeNextLabelNumber() { return NextLabelNumber++; }
60 // Ensure that a 64-bit Variable has been split into 2 32-bit 61 // Ensure that a 64-bit Variable has been split into 2 32-bit
61 // Variables, creating them if necessary. This is needed for all 62 // Variables, creating them if necessary. This is needed for all
62 // I64 operations, and it is needed for pushing F64 arguments for 63 // I64 operations, and it is needed for pushing F64 arguments for
63 // function calls using the 32-bit push instruction (though the 64 // function calls using the 32-bit push instruction (though the
64 // latter could be done by directly writing to the stack). 65 // latter could be done by directly writing to the stack).
65 void split64(Variable *Var); 66 void split64(Variable *Var);
66 void finishArgumentLowering(Variable *Arg, Variable *FramePtr, 67 void finishArgumentLowering(Variable *Arg, Variable *FramePtr,
67 size_t BasicFrameOffset, size_t &InArgsSizeBytes); 68 size_t BasicFrameOffset, size_t &InArgsSizeBytes);
68 Operand *loOperand(Operand *Operand); 69 Operand *loOperand(Operand *Operand);
69 Operand *hiOperand(Operand *Operand); 70 Operand *hiOperand(Operand *Operand);
70 71
71 enum Registers {
72 #define X(val, init, name, name16, name8, scratch, preserved, stackptr, \
73 frameptr, isI8, isInt, isFP) \
74 val init,
75 REGX8632_TABLE
76 #undef X
77 Reg_NUM
78 };
79
80 enum X86InstructionSet { 72 enum X86InstructionSet {
81 // SSE2 is the PNaCl baseline instruction set. 73 // SSE2 is the PNaCl baseline instruction set.
82 SSE2, 74 SSE2,
83 SSE4_1 75 SSE4_1
84 }; 76 };
85 77
86 X86InstructionSet getInstructionSet() const { return InstructionSet; } 78 X86InstructionSet getInstructionSet() const { return InstructionSet; }
87 79
88 protected: 80 protected:
89 TargetX8632(Cfg *Func); 81 TargetX8632(Cfg *Func);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 197 }
206 void _addss(Variable *Dest, Operand *Src0) { 198 void _addss(Variable *Dest, Operand *Src0) {
207 Context.insert(InstX8632Addss::create(Func, Dest, Src0)); 199 Context.insert(InstX8632Addss::create(Func, Dest, Src0));
208 } 200 }
209 void _and(Variable *Dest, Operand *Src0) { 201 void _and(Variable *Dest, Operand *Src0) {
210 Context.insert(InstX8632And::create(Func, Dest, Src0)); 202 Context.insert(InstX8632And::create(Func, Dest, Src0));
211 } 203 }
212 void _blendvps(Variable *Dest, Operand *Src0, Operand *Src1) { 204 void _blendvps(Variable *Dest, Operand *Src0, Operand *Src1) {
213 Context.insert(InstX8632Blendvps::create(Func, Dest, Src0, Src1)); 205 Context.insert(InstX8632Blendvps::create(Func, Dest, Src0, Src1));
214 } 206 }
215 void _br(InstX8632::BrCond Condition, CfgNode *TargetTrue, 207 void _br(CondX86::BrCond Condition, CfgNode *TargetTrue,
216 CfgNode *TargetFalse) { 208 CfgNode *TargetFalse) {
217 Context.insert( 209 Context.insert(
218 InstX8632Br::create(Func, TargetTrue, TargetFalse, Condition)); 210 InstX8632Br::create(Func, TargetTrue, TargetFalse, Condition));
219 } 211 }
220 void _br(CfgNode *Target) { 212 void _br(CfgNode *Target) {
221 Context.insert(InstX8632Br::create(Func, Target)); 213 Context.insert(InstX8632Br::create(Func, Target));
222 } 214 }
223 void _br(InstX8632::BrCond Condition, CfgNode *Target) { 215 void _br(CondX86::BrCond Condition, CfgNode *Target) {
224 Context.insert(InstX8632Br::create(Func, Target, Condition)); 216 Context.insert(InstX8632Br::create(Func, Target, Condition));
225 } 217 }
226 void _br(InstX8632::BrCond Condition, InstX8632Label *Label) { 218 void _br(CondX86::BrCond Condition, InstX8632Label *Label) {
227 Context.insert(InstX8632Br::create(Func, Label, Condition)); 219 Context.insert(InstX8632Br::create(Func, Label, Condition));
228 } 220 }
229 void _bsf(Variable *Dest, Operand *Src0) { 221 void _bsf(Variable *Dest, Operand *Src0) {
230 Context.insert(InstX8632Bsf::create(Func, Dest, Src0)); 222 Context.insert(InstX8632Bsf::create(Func, Dest, Src0));
231 } 223 }
232 void _bsr(Variable *Dest, Operand *Src0) { 224 void _bsr(Variable *Dest, Operand *Src0) {
233 Context.insert(InstX8632Bsr::create(Func, Dest, Src0)); 225 Context.insert(InstX8632Bsr::create(Func, Dest, Src0));
234 } 226 }
235 void _bswap(Variable *SrcDest) { 227 void _bswap(Variable *SrcDest) {
236 Context.insert(InstX8632Bswap::create(Func, SrcDest)); 228 Context.insert(InstX8632Bswap::create(Func, SrcDest));
237 } 229 }
238 void _cbwdq(Variable *Dest, Operand *Src0) { 230 void _cbwdq(Variable *Dest, Operand *Src0) {
239 Context.insert(InstX8632Cbwdq::create(Func, Dest, Src0)); 231 Context.insert(InstX8632Cbwdq::create(Func, Dest, Src0));
240 } 232 }
241 void _cmov(Variable *Dest, Operand *Src0, InstX8632::BrCond Condition) { 233 void _cmov(Variable *Dest, Operand *Src0, CondX86::BrCond Condition) {
242 Context.insert(InstX8632Cmov::create(Func, Dest, Src0, Condition)); 234 Context.insert(InstX8632Cmov::create(Func, Dest, Src0, Condition));
243 } 235 }
244 void _cmp(Operand *Src0, Operand *Src1) { 236 void _cmp(Operand *Src0, Operand *Src1) {
245 Context.insert(InstX8632Icmp::create(Func, Src0, Src1)); 237 Context.insert(InstX8632Icmp::create(Func, Src0, Src1));
246 } 238 }
247 void _cmpps(Variable *Dest, Operand *Src0, 239 void _cmpps(Variable *Dest, Operand *Src0, CondX86::CmppsCond Condition) {
248 InstX8632Cmpps::CmppsCond Condition) {
249 Context.insert(InstX8632Cmpps::create(Func, Dest, Src0, Condition)); 240 Context.insert(InstX8632Cmpps::create(Func, Dest, Src0, Condition));
250 } 241 }
251 void _cmpxchg(Operand *DestOrAddr, Variable *Eax, Variable *Desired, 242 void _cmpxchg(Operand *DestOrAddr, Variable *Eax, Variable *Desired,
252 bool Locked) { 243 bool Locked) {
253 Context.insert( 244 Context.insert(
254 InstX8632Cmpxchg::create(Func, DestOrAddr, Eax, Desired, Locked)); 245 InstX8632Cmpxchg::create(Func, DestOrAddr, Eax, Desired, Locked));
255 // Mark eax as possibly modified by cmpxchg. 246 // Mark eax as possibly modified by cmpxchg.
256 Context.insert( 247 Context.insert(
257 InstFakeDef::create(Func, Eax, llvm::dyn_cast<Variable>(DestOrAddr))); 248 InstFakeDef::create(Func, Eax, llvm::dyn_cast<Variable>(DestOrAddr)));
258 } 249 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 }; 502 };
512 503
513 template <> void ConstantInteger32::emit(GlobalContext *Ctx) const; 504 template <> void ConstantInteger32::emit(GlobalContext *Ctx) const;
514 template <> void ConstantInteger64::emit(GlobalContext *Ctx) const; 505 template <> void ConstantInteger64::emit(GlobalContext *Ctx) const;
515 template <> void ConstantFloat::emit(GlobalContext *Ctx) const; 506 template <> void ConstantFloat::emit(GlobalContext *Ctx) const;
516 template <> void ConstantDouble::emit(GlobalContext *Ctx) const; 507 template <> void ConstantDouble::emit(GlobalContext *Ctx) const;
517 508
518 } // end of namespace Ice 509 } // end of namespace Ice
519 510
520 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H 511 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8632_H
OLDNEW
« no previous file with comments | « src/IceRegistersX8632.h ('k') | src/IceTargetLoweringX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698