OLD | NEW |
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 "IceConditionCodesX8632.h" |
21 #include "IceInstX8632.def" | 22 #include "IceInstX8632.def" |
22 #include "IceOperand.h" | 23 #include "IceOperand.h" |
23 | 24 |
24 namespace Ice { | 25 namespace Ice { |
25 | 26 |
26 class TargetX8632; | 27 class TargetX8632; |
27 | 28 |
28 // OperandX8632 extends the Operand hierarchy. Its subclasses are | 29 // OperandX8632 extends the Operand hierarchy. Its subclasses are |
29 // OperandX8632Mem and VariableSplit. | 30 // OperandX8632Mem and VariableSplit. |
30 class OperandX8632 : public Operand { | 31 class OperandX8632 : public Operand { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 Subps, | 218 Subps, |
218 Subss, | 219 Subss, |
219 Test, | 220 Test, |
220 Ucomiss, | 221 Ucomiss, |
221 UD2, | 222 UD2, |
222 Xadd, | 223 Xadd, |
223 Xchg, | 224 Xchg, |
224 Xor | 225 Xor |
225 }; | 226 }; |
226 | 227 |
227 enum BrCond { | |
228 #define X(tag, opp, dump, emit) tag, | |
229 ICEINSTX8632BR_TABLE | |
230 #undef X | |
231 Br_None | |
232 }; | |
233 | |
234 static const char *getWidthString(Type Ty); | 228 static const char *getWidthString(Type Ty); |
235 virtual void emit(const Cfg *Func) const = 0; | 229 virtual void emit(const Cfg *Func) const = 0; |
236 virtual void dump(const Cfg *Func) const; | 230 virtual void dump(const Cfg *Func) const; |
237 | 231 |
238 protected: | 232 protected: |
239 InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest) | 233 InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest) |
240 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} | 234 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} |
241 virtual ~InstX8632() {} | 235 virtual ~InstX8632() {} |
242 static bool isClassof(const Inst *Inst, InstKindX8632 MyKind) { | 236 static bool isClassof(const Inst *Inst, InstKindX8632 MyKind) { |
243 return Inst->getKind() == static_cast<InstKind>(MyKind); | 237 return Inst->getKind() == static_cast<InstKind>(MyKind); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 InstX8632Label &operator=(const InstX8632Label &) LLVM_DELETED_FUNCTION; | 295 InstX8632Label &operator=(const InstX8632Label &) LLVM_DELETED_FUNCTION; |
302 virtual ~InstX8632Label() {} | 296 virtual ~InstX8632Label() {} |
303 SizeT Number; // used only for unique label string generation | 297 SizeT Number; // used only for unique label string generation |
304 }; | 298 }; |
305 | 299 |
306 // Conditional and unconditional branch instruction. | 300 // Conditional and unconditional branch instruction. |
307 class InstX8632Br : public InstX8632 { | 301 class InstX8632Br : public InstX8632 { |
308 public: | 302 public: |
309 // Create a conditional branch to a node. | 303 // Create a conditional branch to a node. |
310 static InstX8632Br *create(Cfg *Func, CfgNode *TargetTrue, | 304 static InstX8632Br *create(Cfg *Func, CfgNode *TargetTrue, |
311 CfgNode *TargetFalse, BrCond Condition) { | 305 CfgNode *TargetFalse, CondX86::BrCond Condition) { |
312 const InstX8632Label *NoLabel = NULL; | 306 const InstX8632Label *NoLabel = NULL; |
313 return new (Func->allocate<InstX8632Br>()) | 307 return new (Func->allocate<InstX8632Br>()) |
314 InstX8632Br(Func, TargetTrue, TargetFalse, NoLabel, Condition); | 308 InstX8632Br(Func, TargetTrue, TargetFalse, NoLabel, Condition); |
315 } | 309 } |
316 // Create an unconditional branch to a node. | 310 // Create an unconditional branch to a node. |
317 static InstX8632Br *create(Cfg *Func, CfgNode *Target) { | 311 static InstX8632Br *create(Cfg *Func, CfgNode *Target) { |
318 const CfgNode *NoCondTarget = NULL; | 312 const CfgNode *NoCondTarget = NULL; |
319 const InstX8632Label *NoLabel = NULL; | 313 const InstX8632Label *NoLabel = NULL; |
320 return new (Func->allocate<InstX8632Br>()) | 314 return new (Func->allocate<InstX8632Br>()) |
321 InstX8632Br(Func, NoCondTarget, Target, NoLabel, Br_None); | 315 InstX8632Br(Func, NoCondTarget, Target, NoLabel, CondX86::Br_None); |
322 } | 316 } |
323 // Create a non-terminator conditional branch to a node, with a | 317 // Create a non-terminator conditional branch to a node, with a |
324 // fallthrough to the next instruction in the current node. This is | 318 // fallthrough to the next instruction in the current node. This is |
325 // used for switch lowering. | 319 // used for switch lowering. |
326 static InstX8632Br *create(Cfg *Func, CfgNode *Target, BrCond Condition) { | 320 static InstX8632Br *create(Cfg *Func, CfgNode *Target, |
| 321 CondX86::BrCond Condition) { |
327 const CfgNode *NoUncondTarget = NULL; | 322 const CfgNode *NoUncondTarget = NULL; |
328 const InstX8632Label *NoLabel = NULL; | 323 const InstX8632Label *NoLabel = NULL; |
329 return new (Func->allocate<InstX8632Br>()) | 324 return new (Func->allocate<InstX8632Br>()) |
330 InstX8632Br(Func, Target, NoUncondTarget, NoLabel, Condition); | 325 InstX8632Br(Func, Target, NoUncondTarget, NoLabel, Condition); |
331 } | 326 } |
332 // Create a conditional intra-block branch (or unconditional, if | 327 // Create a conditional intra-block branch (or unconditional, if |
333 // Condition==Br_None) to a label in the current block. | 328 // Condition==Br_None) to a label in the current block. |
334 static InstX8632Br *create(Cfg *Func, InstX8632Label *Label, | 329 static InstX8632Br *create(Cfg *Func, InstX8632Label *Label, |
335 BrCond Condition) { | 330 CondX86::BrCond Condition) { |
336 const CfgNode *NoCondTarget = NULL; | 331 const CfgNode *NoCondTarget = NULL; |
337 const CfgNode *NoUncondTarget = NULL; | 332 const CfgNode *NoUncondTarget = NULL; |
338 return new (Func->allocate<InstX8632Br>()) | 333 return new (Func->allocate<InstX8632Br>()) |
339 InstX8632Br(Func, NoCondTarget, NoUncondTarget, Label, Condition); | 334 InstX8632Br(Func, NoCondTarget, NoUncondTarget, Label, Condition); |
340 } | 335 } |
341 const CfgNode *getTargetTrue() const { return TargetTrue; } | 336 const CfgNode *getTargetTrue() const { return TargetTrue; } |
342 const CfgNode *getTargetFalse() const { return TargetFalse; } | 337 const CfgNode *getTargetFalse() const { return TargetFalse; } |
343 bool optimizeBranch(const CfgNode *NextNode); | 338 bool optimizeBranch(const CfgNode *NextNode); |
344 virtual uint32_t getEmitInstCount() const { | 339 virtual uint32_t getEmitInstCount() const { |
345 uint32_t Sum = 0; | 340 uint32_t Sum = 0; |
346 if (Label) | 341 if (Label) |
347 ++Sum; | 342 ++Sum; |
348 if (getTargetTrue()) | 343 if (getTargetTrue()) |
349 ++Sum; | 344 ++Sum; |
350 if (getTargetFalse()) | 345 if (getTargetFalse()) |
351 ++Sum; | 346 ++Sum; |
352 return Sum; | 347 return Sum; |
353 } | 348 } |
354 virtual void emit(const Cfg *Func) const; | 349 virtual void emit(const Cfg *Func) const; |
355 virtual void dump(const Cfg *Func) const; | 350 virtual void dump(const Cfg *Func) const; |
356 static bool classof(const Inst *Inst) { return isClassof(Inst, Br); } | 351 static bool classof(const Inst *Inst) { return isClassof(Inst, Br); } |
357 | 352 |
358 private: | 353 private: |
359 InstX8632Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, | 354 InstX8632Br(Cfg *Func, const CfgNode *TargetTrue, const CfgNode *TargetFalse, |
360 const InstX8632Label *Label, BrCond Condition); | 355 const InstX8632Label *Label, CondX86::BrCond Condition); |
361 InstX8632Br(const InstX8632Br &) LLVM_DELETED_FUNCTION; | 356 InstX8632Br(const InstX8632Br &) LLVM_DELETED_FUNCTION; |
362 InstX8632Br &operator=(const InstX8632Br &) LLVM_DELETED_FUNCTION; | 357 InstX8632Br &operator=(const InstX8632Br &) LLVM_DELETED_FUNCTION; |
363 virtual ~InstX8632Br() {} | 358 virtual ~InstX8632Br() {} |
364 BrCond Condition; | 359 CondX86::BrCond Condition; |
365 const CfgNode *TargetTrue; | 360 const CfgNode *TargetTrue; |
366 const CfgNode *TargetFalse; | 361 const CfgNode *TargetFalse; |
367 const InstX8632Label *Label; // Intra-block branch target | 362 const InstX8632Label *Label; // Intra-block branch target |
368 }; | 363 }; |
369 | 364 |
370 // AdjustStack instruction - subtracts esp by the given amount and | 365 // AdjustStack instruction - subtracts esp by the given amount and |
371 // updates the stack offset during code emission. | 366 // updates the stack offset during code emission. |
372 class InstX8632AdjustStack : public InstX8632 { | 367 class InstX8632AdjustStack : public InstX8632 { |
373 public: | 368 public: |
374 static InstX8632AdjustStack *create(Cfg *Func, SizeT Amount) { | 369 static InstX8632AdjustStack *create(Cfg *Func, SizeT Amount) { |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 Variable *Source2); | 768 Variable *Source2); |
774 InstX8632Shrd(const InstX8632Shrd &) LLVM_DELETED_FUNCTION; | 769 InstX8632Shrd(const InstX8632Shrd &) LLVM_DELETED_FUNCTION; |
775 InstX8632Shrd &operator=(const InstX8632Shrd &) LLVM_DELETED_FUNCTION; | 770 InstX8632Shrd &operator=(const InstX8632Shrd &) LLVM_DELETED_FUNCTION; |
776 virtual ~InstX8632Shrd() {} | 771 virtual ~InstX8632Shrd() {} |
777 }; | 772 }; |
778 | 773 |
779 // Conditional move instruction. | 774 // Conditional move instruction. |
780 class InstX8632Cmov : public InstX8632 { | 775 class InstX8632Cmov : public InstX8632 { |
781 public: | 776 public: |
782 static InstX8632Cmov *create(Cfg *Func, Variable *Dest, Operand *Source, | 777 static InstX8632Cmov *create(Cfg *Func, Variable *Dest, Operand *Source, |
783 BrCond Cond) { | 778 CondX86::BrCond Cond) { |
784 return new (Func->allocate<InstX8632Cmov>()) | 779 return new (Func->allocate<InstX8632Cmov>()) |
785 InstX8632Cmov(Func, Dest, Source, Cond); | 780 InstX8632Cmov(Func, Dest, Source, Cond); |
786 } | 781 } |
787 virtual void emit(const Cfg *Func) const; | 782 virtual void emit(const Cfg *Func) const; |
788 virtual void dump(const Cfg *Func) const; | 783 virtual void dump(const Cfg *Func) const; |
789 static bool classof(const Inst *Inst) { return isClassof(Inst, Cmov); } | 784 static bool classof(const Inst *Inst) { return isClassof(Inst, Cmov); } |
790 | 785 |
791 private: | 786 private: |
792 InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, BrCond Cond); | 787 InstX8632Cmov(Cfg *Func, Variable *Dest, Operand *Source, |
| 788 CondX86::BrCond Cond); |
793 InstX8632Cmov(const InstX8632Cmov &) LLVM_DELETED_FUNCTION; | 789 InstX8632Cmov(const InstX8632Cmov &) LLVM_DELETED_FUNCTION; |
794 InstX8632Cmov &operator=(const InstX8632Cmov &) LLVM_DELETED_FUNCTION; | 790 InstX8632Cmov &operator=(const InstX8632Cmov &) LLVM_DELETED_FUNCTION; |
795 virtual ~InstX8632Cmov() {} | 791 virtual ~InstX8632Cmov() {} |
796 | 792 |
797 BrCond Condition; | 793 CondX86::BrCond Condition; |
798 }; | 794 }; |
799 | 795 |
800 // Cmpps instruction - compare packed singled-precision floating point | 796 // Cmpps instruction - compare packed singled-precision floating point |
801 // values | 797 // values |
802 class InstX8632Cmpps : public InstX8632 { | 798 class InstX8632Cmpps : public InstX8632 { |
803 public: | 799 public: |
804 enum CmppsCond { | |
805 #define X(tag, emit) tag, | |
806 ICEINSTX8632CMPPS_TABLE | |
807 #undef X | |
808 Cmpps_Invalid | |
809 }; | |
810 | |
811 static InstX8632Cmpps *create(Cfg *Func, Variable *Dest, Operand *Source, | 800 static InstX8632Cmpps *create(Cfg *Func, Variable *Dest, Operand *Source, |
812 CmppsCond Condition) { | 801 CondX86::CmppsCond Condition) { |
813 return new (Func->allocate<InstX8632Cmpps>()) | 802 return new (Func->allocate<InstX8632Cmpps>()) |
814 InstX8632Cmpps(Func, Dest, Source, Condition); | 803 InstX8632Cmpps(Func, Dest, Source, Condition); |
815 } | 804 } |
816 virtual void emit(const Cfg *Func) const; | 805 virtual void emit(const Cfg *Func) const; |
817 virtual void dump(const Cfg *Func) const; | 806 virtual void dump(const Cfg *Func) const; |
818 static bool classof(const Inst *Inst) { return isClassof(Inst, Cmpps); } | 807 static bool classof(const Inst *Inst) { return isClassof(Inst, Cmpps); } |
819 | 808 |
820 private: | 809 private: |
821 InstX8632Cmpps(Cfg *Func, Variable *Dest, Operand *Source, CmppsCond Cond); | 810 InstX8632Cmpps(Cfg *Func, Variable *Dest, Operand *Source, |
| 811 CondX86::CmppsCond Cond); |
822 InstX8632Cmpps(const InstX8632Cmpps &) LLVM_DELETED_FUNCTION; | 812 InstX8632Cmpps(const InstX8632Cmpps &) LLVM_DELETED_FUNCTION; |
823 InstX8632Cmpps &operator=(const InstX8632Cmpps &) LLVM_DELETED_FUNCTION; | 813 InstX8632Cmpps &operator=(const InstX8632Cmpps &) LLVM_DELETED_FUNCTION; |
824 virtual ~InstX8632Cmpps() {} | 814 virtual ~InstX8632Cmpps() {} |
825 | 815 |
826 CmppsCond Condition; | 816 CondX86::CmppsCond Condition; |
827 }; | 817 }; |
828 | 818 |
829 // Cmpxchg instruction - cmpxchg <dest>, <desired> will compare if <dest> | 819 // Cmpxchg instruction - cmpxchg <dest>, <desired> will compare if <dest> |
830 // equals eax. If so, the ZF is set and <desired> is stored in <dest>. | 820 // equals eax. If so, the ZF is set and <desired> is stored in <dest>. |
831 // If not, ZF is cleared and <dest> is copied to eax (or subregister). | 821 // If not, ZF is cleared and <dest> is copied to eax (or subregister). |
832 // <dest> can be a register or memory, while <desired> must be a register. | 822 // <dest> can be a register or memory, while <desired> must be a register. |
833 // It is the user's responsiblity to mark eax with a FakeDef. | 823 // It is the user's responsiblity to mark eax with a FakeDef. |
834 class InstX8632Cmpxchg : public InstX8632Lockable { | 824 class InstX8632Cmpxchg : public InstX8632Lockable { |
835 public: | 825 public: |
836 static InstX8632Cmpxchg *create(Cfg *Func, Operand *DestOrAddr, Variable *Eax, | 826 static InstX8632Cmpxchg *create(Cfg *Func, Operand *DestOrAddr, Variable *Eax, |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 template <> void InstX8632Pmuludq::emit(const Cfg *Func) const; | 1254 template <> void InstX8632Pmuludq::emit(const Cfg *Func) const; |
1265 template <> void InstX8632Psll::emit(const Cfg *Func) const; | 1255 template <> void InstX8632Psll::emit(const Cfg *Func) const; |
1266 template <> void InstX8632Psra::emit(const Cfg *Func) const; | 1256 template <> void InstX8632Psra::emit(const Cfg *Func) const; |
1267 template <> void InstX8632Psub::emit(const Cfg *Func) const; | 1257 template <> void InstX8632Psub::emit(const Cfg *Func) const; |
1268 template <> void InstX8632Sqrtss::emit(const Cfg *Func) const; | 1258 template <> void InstX8632Sqrtss::emit(const Cfg *Func) const; |
1269 template <> void InstX8632Subss::emit(const Cfg *Func) const; | 1259 template <> void InstX8632Subss::emit(const Cfg *Func) const; |
1270 | 1260 |
1271 } // end of namespace Ice | 1261 } // end of namespace Ice |
1272 | 1262 |
1273 #endif // SUBZERO_SRC_ICEINSTX8632_H | 1263 #endif // SUBZERO_SRC_ICEINSTX8632_H |
OLD | NEW |