Chromium Code Reviews

Side by Side Diff: src/IceInstX8632.h

Issue 321993002: Add a few Subzero intrinsics (not the atomic ones yet). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: doesn't matter if eax or not Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 //===- subzero/src/IceInstX8632.h - Low-level x86 instructions --*- C++ -*-===// 1 //===- subzero/src/IceInstX8632.h - Low-level x86 instructions --*- 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 InstX8632 and OperandX8632 classes and 10 // This file declares the InstX8632 and OperandX8632 classes and
11 // their subclasses. This represents the machine instructions and 11 // their subclasses. This represents the machine instructions and
12 // operands used for x86-32 code selection. 12 // operands used for x86-32 code selection.
13 // 13 //
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #ifndef SUBZERO_SRC_ICEINSTX8632_H 16 #ifndef SUBZERO_SRC_ICEINSTX8632_H
17 #define SUBZERO_SRC_ICEINSTX8632_H 17 #define SUBZERO_SRC_ICEINSTX8632_H
18 18
19 #include "IceDefs.h" 19 #include "IceDefs.h"
20 #include "IceInst.h" 20 #include "IceInst.h"
21 #include "IceInstX8632.def" 21 #include "IceInstX8632.def"
22 #include "IceOperand.h" 22 #include "IceOperand.h"
23 23
24 namespace Ice { 24 namespace Ice {
25 25
26 class TargetX8632; 26 class TargetX8632;
27 27
28 // OperandX8632 extends the Operand hierarchy. Its subclasses are 28 // OperandX8632 extends the Operand hierarchy. Its subclasses are
29 // OperandX8632Mem and VariableSplit. 29 // OperandX8632Mem, OperandX8632MemOffSeg, and VariableSplit.
30 class OperandX8632 : public Operand { 30 class OperandX8632 : public Operand {
31 public: 31 public:
32 enum OperandKindX8632 { 32 enum OperandKindX8632 {
33 k__Start = Operand::kTarget, 33 k__Start = Operand::kTarget,
34 kMem, 34 kMem,
35 kMemOffSeg,
35 kSplit 36 kSplit
36 }; 37 };
37 virtual void emit(const Cfg *Func) const = 0; 38 virtual void emit(const Cfg *Func) const = 0;
38 void dump(const Cfg *Func) const; 39 void dump(const Cfg *Func) const;
39 40
40 protected: 41 protected:
41 OperandX8632(OperandKindX8632 Kind, Type Ty) 42 OperandX8632(OperandKindX8632 Kind, Type Ty)
42 : Operand(static_cast<OperandKind>(Kind), Ty) {} 43 : Operand(static_cast<OperandKind>(Kind), Ty) {}
43 virtual ~OperandX8632() {} 44 virtual ~OperandX8632() {}
44 45
(...skipping 29 matching lines...)
74 Variable *Index, uint32_t Shift); 75 Variable *Index, uint32_t Shift);
75 OperandX8632Mem(const OperandX8632Mem &) LLVM_DELETED_FUNCTION; 76 OperandX8632Mem(const OperandX8632Mem &) LLVM_DELETED_FUNCTION;
76 OperandX8632Mem &operator=(const OperandX8632Mem &) LLVM_DELETED_FUNCTION; 77 OperandX8632Mem &operator=(const OperandX8632Mem &) LLVM_DELETED_FUNCTION;
77 virtual ~OperandX8632Mem() {} 78 virtual ~OperandX8632Mem() {}
78 Variable *Base; 79 Variable *Base;
79 Constant *Offset; 80 Constant *Offset;
80 Variable *Index; 81 Variable *Index;
81 uint32_t Shift; 82 uint32_t Shift;
82 }; 83 };
83 84
85 // OperandX8632MemOffSeg represents the moffs addressing mode, where
86 // the address is given by an offset relative to the segment base.
87 class OperandX8632MemOffSeg : public OperandX8632 {
Jim Stichnoth 2014/06/10 22:58:28 Instead of creating this new class, couldn't we ju
jvoung (off chromium) 2014/06/12 05:48:30 Done. The initial concern was that we would be wa
Jim Stichnoth 2014/06/12 20:52:06 You're right, I should have been looking at create
88 public:
89 static OperandX8632MemOffSeg *create(Cfg *Func, Type Ty,
90 Constant *Offset,
91 SizeT SegmentReg) {
92 return new (Func->allocate<OperandX8632MemOffSeg>())
93 OperandX8632MemOffSeg(Ty, Offset, SegmentReg);
94 }
95 Constant *getOffset() const { return Offset; }
96 SizeT getSegmentRegister() const { return SegmentReg; }
JF 2014/06/10 03:50:41 It seems weird to have SegmentReg as a SizeT. Shou
Jim Stichnoth 2014/06/10 22:58:28 The regular registers are using int32_t, but I won
jvoung (off chromium) 2014/06/12 05:48:30 Moved to using the enum.
97 virtual void emit(const Cfg *Func) const;
98 virtual void dump(const Cfg *Func) const;
99
100 static bool classof(const Operand *Operand) {
101 return Operand->getKind() == static_cast<OperandKind>(kMemOffSeg);
102 }
103
104 private:
105 OperandX8632MemOffSeg(Type Ty, Constant *Offset, SizeT SegmentReg)
106 : OperandX8632(kMemOffSeg, Ty), Offset(Offset), SegmentReg(SegmentReg) {}
107 OperandX8632MemOffSeg(
108 const OperandX8632MemOffSeg &) LLVM_DELETED_FUNCTION;
109 OperandX8632MemOffSeg &operator=(
110 const OperandX8632MemOffSeg &) LLVM_DELETED_FUNCTION;
111 virtual ~OperandX8632MemOffSeg() {}
112 Constant *Offset;
113 SizeT SegmentReg;
114 };
115
84 // VariableSplit is a way to treat an f64 memory location as a pair 116 // VariableSplit is a way to treat an f64 memory location as a pair
85 // of i32 locations (Low and High). This is needed for some cases 117 // of i32 locations (Low and High). This is needed for some cases
86 // of the Bitcast instruction. Since it's not possible for integer 118 // of the Bitcast instruction. Since it's not possible for integer
87 // registers to access the XMM registers and vice versa, the 119 // registers to access the XMM registers and vice versa, the
88 // lowering forces the f64 to be spilled to the stack and then 120 // lowering forces the f64 to be spilled to the stack and then
89 // accesses through the VariableSplit. 121 // accesses through the VariableSplit.
90 class VariableSplit : public OperandX8632 { 122 class VariableSplit : public OperandX8632 {
91 public: 123 public:
92 enum Portion { 124 enum Portion {
93 Low, 125 Low,
(...skipping 59 matching lines...)
153 Sbb, 185 Sbb,
154 Shl, 186 Shl,
155 Shld, 187 Shld,
156 Shr, 188 Shr,
157 Shrd, 189 Shrd,
158 Store, 190 Store,
159 Sub, 191 Sub,
160 Subss, 192 Subss,
161 Test, 193 Test,
162 Ucomiss, 194 Ucomiss,
195 UD2,
163 Xor 196 Xor
164 }; 197 };
165 static const char *getWidthString(Type Ty); 198 static const char *getWidthString(Type Ty);
166 virtual void emit(const Cfg *Func) const = 0; 199 virtual void emit(const Cfg *Func) const = 0;
167 virtual void dump(const Cfg *Func) const; 200 virtual void dump(const Cfg *Func) const;
168 201
169 protected: 202 protected:
170 InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest) 203 InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest)
171 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} 204 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {}
172 virtual ~InstX8632() {} 205 virtual ~InstX8632() {}
(...skipping 351 matching lines...)
524 virtual void dump(const Cfg *Func) const; 557 virtual void dump(const Cfg *Func) const;
525 static bool classof(const Inst *Inst) { return isClassof(Inst, Ucomiss); } 558 static bool classof(const Inst *Inst) { return isClassof(Inst, Ucomiss); }
526 559
527 private: 560 private:
528 InstX8632Ucomiss(Cfg *Func, Operand *Src1, Operand *Src2); 561 InstX8632Ucomiss(Cfg *Func, Operand *Src1, Operand *Src2);
529 InstX8632Ucomiss(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; 562 InstX8632Ucomiss(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION;
530 InstX8632Ucomiss &operator=(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION; 563 InstX8632Ucomiss &operator=(const InstX8632Ucomiss &) LLVM_DELETED_FUNCTION;
531 virtual ~InstX8632Ucomiss() {} 564 virtual ~InstX8632Ucomiss() {}
532 }; 565 };
533 566
567 // UD2 instruction.
568 class InstX8632UD2 : public InstX8632 {
569 public:
570 static InstX8632UD2 *create(Cfg *Func) {
571 return new (Func->allocate<InstX8632UD2>())
572 InstX8632UD2(Func);
573 }
574 virtual void emit(const Cfg *Func) const;
575 virtual void dump(const Cfg *Func) const;
576 static bool classof(const Inst *Inst) { return isClassof(Inst, UD2); }
577
578 private:
579 InstX8632UD2(Cfg *Func);
580 InstX8632UD2(const InstX8632UD2 &) LLVM_DELETED_FUNCTION;
581 InstX8632UD2 &operator=(const InstX8632UD2 &) LLVM_DELETED_FUNCTION;
582 virtual ~InstX8632UD2() {}
583 };
584
534 // Test instruction. 585 // Test instruction.
535 class InstX8632Test : public InstX8632 { 586 class InstX8632Test : public InstX8632 {
536 public: 587 public:
537 static InstX8632Test *create(Cfg *Func, Operand *Source1, Operand *Source2) { 588 static InstX8632Test *create(Cfg *Func, Operand *Source1, Operand *Source2) {
538 return new (Func->allocate<InstX8632Test>()) 589 return new (Func->allocate<InstX8632Test>())
539 InstX8632Test(Func, Source1, Source2); 590 InstX8632Test(Func, Source1, Source2);
540 } 591 }
541 virtual void emit(const Cfg *Func) const; 592 virtual void emit(const Cfg *Func) const;
542 virtual void dump(const Cfg *Func) const; 593 virtual void dump(const Cfg *Func) const;
543 static bool classof(const Inst *Inst) { return isClassof(Inst, Test); } 594 static bool classof(const Inst *Inst) { return isClassof(Inst, Test); }
(...skipping 167 matching lines...)
711 private: 762 private:
712 InstX8632Ret(Cfg *Func, Variable *Source); 763 InstX8632Ret(Cfg *Func, Variable *Source);
713 InstX8632Ret(const InstX8632Ret &) LLVM_DELETED_FUNCTION; 764 InstX8632Ret(const InstX8632Ret &) LLVM_DELETED_FUNCTION;
714 InstX8632Ret &operator=(const InstX8632Ret &) LLVM_DELETED_FUNCTION; 765 InstX8632Ret &operator=(const InstX8632Ret &) LLVM_DELETED_FUNCTION;
715 virtual ~InstX8632Ret() {} 766 virtual ~InstX8632Ret() {}
716 }; 767 };
717 768
718 } // end of namespace Ice 769 } // end of namespace Ice
719 770
720 #endif // SUBZERO_SRC_ICEINSTX8632_H 771 #endif // SUBZERO_SRC_ICEINSTX8632_H
OLDNEW

Powered by Google App Engine