OLD | NEW |
1 //===- subzero/src/IceTargetLoweringX8664Traits.h - x86-64 traits -*- C++ -*-=// | 1 //===- subzero/src/IceTargetLoweringX8664Traits.h - x86-64 traits -*- 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 /// \file | 10 /// \file |
11 /// This file declares the X8664 Target Lowering Traits. | 11 /// This file declares the X8664 Target Lowering Traits. |
12 /// | 12 /// |
13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
14 | 14 |
15 #ifndef SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H | 15 #ifndef SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H |
16 #define SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H | 16 #define SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H |
17 | 17 |
18 #include "IceAssembler.h" | 18 #include "IceAssembler.h" |
19 #include "IceConditionCodesX8664.h" | 19 #include "IceConditionCodesX8664.h" |
20 #include "IceDefs.h" | 20 #include "IceDefs.h" |
21 #include "IceInst.h" | 21 #include "IceInst.h" |
22 #include "IceInstX8664.def" | 22 #include "IceInstX8664.def" |
23 #include "IceOperand.h" | 23 #include "IceOperand.h" |
24 #include "IceRegistersX8664.h" | 24 #include "IceRegistersX8664.h" |
25 #include "IceTargetLowering.h" | 25 #include "IceTargetLowering.h" |
| 26 #include "IceTargetLoweringX8664.def" |
26 | 27 |
27 namespace Ice { | 28 namespace Ice { |
28 | 29 |
29 class TargetX8664; | 30 class TargetX8664; |
30 | 31 |
31 namespace X8664 { | 32 namespace X8664 { |
32 class AssemblerX8664; | 33 class AssemblerX8664; |
33 } // end of namespace X8664 | 34 } // end of namespace X8664 |
34 | 35 |
35 namespace X86Internal { | 36 namespace X86Internal { |
36 | 37 |
37 template <class Machine> struct Insts; | 38 template <class Machine> struct Insts; |
38 template <class Machine> struct MachineTraits; | 39 template <class Machine> struct MachineTraits; |
| 40 template <class Machine> class TargetX86Base; |
39 | 41 |
40 template <> struct MachineTraits<TargetX8664> { | 42 template <> struct MachineTraits<TargetX8664> { |
41 //---------------------------------------------------------------------------- | 43 //---------------------------------------------------------------------------- |
42 // ______ ______ __ __ | 44 // ______ ______ __ __ |
43 // /\ __ \/\ ___\/\ "-./ \ | 45 // /\ __ \/\ ___\/\ "-./ \ |
44 // \ \ __ \ \___ \ \ \-./\ \ | 46 // \ \ __ \ \___ \ \ \-./\ \ |
45 // \ \_\ \_\/\_____\ \_\ \ \_\ | 47 // \ \_\ \_\/\_____\ \_\ \ \_\ |
46 // \/_/\/_/\/_____/\/_/ \/_/ | 48 // \/_/\/_/\/_____/\/_/ \/_/ |
47 // | 49 // |
48 //---------------------------------------------------------------------------- | 50 //---------------------------------------------------------------------------- |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 }; | 277 }; |
276 | 278 |
277 //---------------------------------------------------------------------------- | 279 //---------------------------------------------------------------------------- |
278 // __ ______ __ __ ______ ______ __ __ __ ______ | 280 // __ ______ __ __ ______ ______ __ __ __ ______ |
279 // /\ \ /\ __ \/\ \ _ \ \/\ ___\/\ == \/\ \/\ "-.\ \/\ ___\ | 281 // /\ \ /\ __ \/\ \ _ \ \/\ ___\/\ == \/\ \/\ "-.\ \/\ ___\ |
280 // \ \ \___\ \ \/\ \ \ \/ ".\ \ \ __\\ \ __<\ \ \ \ \-. \ \ \__ \ | 282 // \ \ \___\ \ \/\ \ \ \/ ".\ \ \ __\\ \ __<\ \ \ \ \-. \ \ \__ \ |
281 // \ \_____\ \_____\ \__/".~\_\ \_____\ \_\ \_\ \_\ \_\\"\_\ \_____\ | 283 // \ \_____\ \_____\ \__/".~\_\ \_____\ \_\ \_\ \_\ \_\\"\_\ \_____\ |
282 // \/_____/\/_____/\/_/ \/_/\/_____/\/_/ /_/\/_/\/_/ \/_/\/_____/ | 284 // \/_____/\/_____/\/_/ \/_/\/_____/\/_/ /_/\/_/\/_/ \/_/\/_____/ |
283 // | 285 // |
284 //---------------------------------------------------------------------------- | 286 //---------------------------------------------------------------------------- |
| 287 enum InstructionSet { |
| 288 Begin, |
| 289 // SSE2 is the PNaCl baseline instruction set. |
| 290 SSE2 = Begin, |
| 291 SSE4_1, |
| 292 End |
| 293 }; |
| 294 |
| 295 static const char *TargetName; |
| 296 |
| 297 static IceString getRegName(SizeT RegNum, Type Ty) { |
| 298 assert(RegNum < RegisterSet::Reg_NUM); |
| 299 static const struct { |
| 300 const char *const Name8; |
| 301 const char *const Name16; |
| 302 const char *const Name/*32*/; |
| 303 const char *const Name64; |
| 304 } RegNames[] = { |
| 305 #define X(val, encode, name64, name32, name16, name8, scratch, preserved, stackp
tr, \ |
| 306 frameptr, isInt, isFP) \ |
| 307 { name8, name16, name32, name64 }, |
| 308 REGX8664_TABLE |
| 309 #undef X |
| 310 }; |
| 311 |
| 312 switch (Ty) { |
| 313 case IceType_i1: |
| 314 case IceType_i8: |
| 315 return RegNames[RegNum].Name8; |
| 316 case IceType_i16: |
| 317 return RegNames[RegNum].Name16; |
| 318 case IceType_i64: |
| 319 return RegNames[RegNum].Name64; |
| 320 default: |
| 321 return RegNames[RegNum].Name; |
| 322 } |
| 323 } |
| 324 |
| 325 static void initRegisterSet(llvm::SmallBitVector *IntegerRegisters, |
| 326 llvm::SmallBitVector *IntegerRegistersI8, |
| 327 llvm::SmallBitVector *FloatRegisters, |
| 328 llvm::SmallBitVector *VectorRegisters, |
| 329 llvm::SmallBitVector *ScratchRegs) { |
| 330 #define X(val, encode, name64, name32, name16, name8, scratch, preserved, stackp
tr, \ |
| 331 frameptr, isInt, isFP) \ |
| 332 (*IntegerRegisters)[RegisterSet::val] = isInt; \ |
| 333 (*IntegerRegistersI8)[RegisterSet::val] = 1; \ |
| 334 (*FloatRegisters)[RegisterSet::val] = isFP; \ |
| 335 (*VectorRegisters)[RegisterSet::val] = isFP; \ |
| 336 (*ScratchRegs)[RegisterSet::val] = scratch; |
| 337 REGX8664_TABLE; |
| 338 #undef X |
| 339 } |
| 340 |
| 341 static llvm::SmallBitVector |
| 342 getRegisterSet(TargetLowering::RegSetMask Include, |
| 343 TargetLowering::RegSetMask Exclude) { |
| 344 llvm::SmallBitVector Registers(RegisterSet::Reg_NUM); |
| 345 |
| 346 #define X(val, encode, name64, name32, name16, name8, scratch, preserved, stackp
tr, \ |
| 347 frameptr, isInt, isFP) \ |
| 348 if (scratch && (Include & ::Ice::TargetLowering::RegSet_CallerSave)) \ |
| 349 Registers[RegisterSet::val] = true; \ |
| 350 if (preserved && (Include & ::Ice::TargetLowering::RegSet_CalleeSave)) \ |
| 351 Registers[RegisterSet::val] = true; \ |
| 352 if (stackptr && (Include & ::Ice::TargetLowering::RegSet_StackPointer)) \ |
| 353 Registers[RegisterSet::val] = true; \ |
| 354 if (frameptr && (Include & ::Ice::TargetLowering::RegSet_FramePointer)) \ |
| 355 Registers[RegisterSet::val] = true; \ |
| 356 if (scratch && (Exclude & ::Ice::TargetLowering::RegSet_CallerSave)) \ |
| 357 Registers[RegisterSet::val] = false; \ |
| 358 if (preserved && (Exclude & ::Ice::TargetLowering::RegSet_CalleeSave)) \ |
| 359 Registers[RegisterSet::val] = false; \ |
| 360 if (stackptr && (Exclude & ::Ice::TargetLowering::RegSet_StackPointer)) \ |
| 361 Registers[RegisterSet::val] = false; \ |
| 362 if (frameptr && (Exclude & ::Ice::TargetLowering::RegSet_FramePointer)) \ |
| 363 Registers[RegisterSet::val] = false; |
| 364 |
| 365 REGX8664_TABLE |
| 366 |
| 367 #undef X |
| 368 |
| 369 return Registers; |
| 370 } |
| 371 |
| 372 static void |
| 373 makeRandomRegisterPermutation(GlobalContext *Ctx, Cfg *Func, |
| 374 llvm::SmallVectorImpl<int32_t> &Permutation, |
| 375 const llvm::SmallBitVector &ExcludeRegisters) { |
| 376 // TODO(stichnot): Declaring Permutation this way loses type/size |
| 377 // information. Fix this in conjunction with the caller-side TODO. |
| 378 assert(Permutation.size() >= RegisterSet::Reg_NUM); |
| 379 // Expected upper bound on the number of registers in a single equivalence |
| 380 // class. For x86-64, this would comprise the 16 XMM registers. This is |
| 381 // for performance, not correctness. |
| 382 static const unsigned MaxEquivalenceClassSize = 8; |
| 383 typedef llvm::SmallVector<int32_t, MaxEquivalenceClassSize> RegisterList; |
| 384 typedef std::map<uint32_t, RegisterList> EquivalenceClassMap; |
| 385 EquivalenceClassMap EquivalenceClasses; |
| 386 SizeT NumShuffled = 0, NumPreserved = 0; |
| 387 |
| 388 // Build up the equivalence classes of registers by looking at the register |
| 389 // properties as well as whether the registers should be explicitly excluded |
| 390 // from shuffling. |
| 391 #define X(val, encode, name64, name32, name16, name8, scratch, preserved, stackp
tr, \ |
| 392 frameptr, isInt, isFP) \ |
| 393 if (ExcludeRegisters[RegisterSet::val]) { \ |
| 394 /* val stays the same in the resulting permutation. */ \ |
| 395 Permutation[RegisterSet::val] = RegisterSet::val; \ |
| 396 ++NumPreserved; \ |
| 397 } else { \ |
| 398 const uint32_t Index = (scratch << 0) | (preserved << 1) | (/*isI8=*/1 << 2)
| \ |
| 399 (isInt << 3) | (isFP << 4); \ |
| 400 /* val is assigned to an equivalence class based on its properties. */ \ |
| 401 EquivalenceClasses[Index].push_back(RegisterSet::val); \ |
| 402 } |
| 403 REGX8664_TABLE |
| 404 #undef X |
| 405 |
| 406 RandomNumberGeneratorWrapper RNG(Ctx->getRNG()); |
| 407 |
| 408 // Shuffle the resulting equivalence classes. |
| 409 for (auto I : EquivalenceClasses) { |
| 410 const RegisterList &List = I.second; |
| 411 RegisterList Shuffled(List); |
| 412 RandomShuffle(Shuffled.begin(), Shuffled.end(), RNG); |
| 413 for (size_t SI = 0, SE = Shuffled.size(); SI < SE; ++SI) { |
| 414 Permutation[List[SI]] = Shuffled[SI]; |
| 415 ++NumShuffled; |
| 416 } |
| 417 } |
| 418 |
| 419 assert(NumShuffled + NumPreserved == RegisterSet::Reg_NUM); |
| 420 |
| 421 if (Func->isVerbose(IceV_Random)) { |
| 422 OstreamLocker L(Func->getContext()); |
| 423 Ostream &Str = Func->getContext()->getStrDump(); |
| 424 Str << "Register equivalence classes:\n"; |
| 425 for (auto I : EquivalenceClasses) { |
| 426 Str << "{"; |
| 427 const RegisterList &List = I.second; |
| 428 bool First = true; |
| 429 for (int32_t Register : List) { |
| 430 if (!First) |
| 431 Str << " "; |
| 432 First = false; |
| 433 Str << getRegName(Register, IceType_i32); |
| 434 } |
| 435 Str << "}\n"; |
| 436 } |
| 437 } |
| 438 } |
| 439 |
| 440 /// The maximum number of arguments to pass in XMM registers |
| 441 static const uint32_t X86_MAX_XMM_ARGS = 4; |
| 442 /// The number of bits in a byte |
| 443 static const uint32_t X86_CHAR_BIT = 8; |
| 444 /// Stack alignment. This is defined in IceTargetLoweringX8664.cpp because it |
| 445 /// is used as an argument to std::max(), and the default std::less<T> has an |
| 446 /// operator(T const&, T const&) which requires this member to have an |
| 447 /// address. |
| 448 static const uint32_t X86_STACK_ALIGNMENT_BYTES; |
| 449 /// Size of the return address on the stack |
| 450 static const uint32_t X86_RET_IP_SIZE_BYTES = 4; |
| 451 /// The number of different NOP instructions |
| 452 static const uint32_t X86_NUM_NOP_VARIANTS = 5; |
| 453 |
| 454 /// Value is in bytes. Return Value adjusted to the next highest multiple |
| 455 /// of the stack alignment. |
| 456 static uint32_t applyStackAlignment(uint32_t Value) { |
| 457 return Utils::applyAlignment(Value, X86_STACK_ALIGNMENT_BYTES); |
| 458 } |
| 459 |
| 460 /// Return the type which the elements of the vector have in the X86 |
| 461 /// representation of the vector. |
| 462 static Type getInVectorElementType(Type Ty) { |
| 463 assert(isVectorType(Ty)); |
| 464 size_t Index = static_cast<size_t>(Ty); |
| 465 (void)Index; |
| 466 assert(Index < TableTypeX8664AttributesSize); |
| 467 return TableTypeX8664Attributes[Ty].InVectorElementType; |
| 468 } |
| 469 |
| 470 // Note: The following data structures are defined in |
| 471 // IceTargetLoweringX8664.cpp. |
| 472 |
| 473 /// The following table summarizes the logic for lowering the fcmp |
| 474 /// instruction. There is one table entry for each of the 16 conditions. |
| 475 /// |
| 476 /// The first four columns describe the case when the operands are floating |
| 477 /// point scalar values. A comment in lowerFcmp() describes the lowering |
| 478 /// template. In the most general case, there is a compare followed by two |
| 479 /// conditional branches, because some fcmp conditions don't map to a single |
| 480 /// x86 conditional branch. However, in many cases it is possible to swap the |
| 481 /// operands in the comparison and have a single conditional branch. Since |
| 482 /// it's quite tedious to validate the table by hand, good execution tests are |
| 483 /// helpful. |
| 484 /// |
| 485 /// The last two columns describe the case when the operands are vectors of |
| 486 /// floating point values. For most fcmp conditions, there is a clear mapping |
| 487 /// to a single x86 cmpps instruction variant. Some fcmp conditions require |
| 488 /// special code to handle and these are marked in the table with a |
| 489 /// Cmpps_Invalid predicate. |
| 490 /// {@ |
| 491 static const struct TableFcmpType { |
| 492 uint32_t Default; |
| 493 bool SwapScalarOperands; |
| 494 Cond::BrCond C1, C2; |
| 495 bool SwapVectorOperands; |
| 496 Cond::CmppsCond Predicate; |
| 497 } TableFcmp[]; |
| 498 static const size_t TableFcmpSize; |
| 499 /// @} |
| 500 |
| 501 /// The following table summarizes the logic for lowering the icmp instruction |
| 502 /// for i32 and narrower types. Each icmp condition has a clear mapping to an |
| 503 /// x86 conditional branch instruction. |
| 504 /// {@ |
| 505 static const struct TableIcmp32Type { Cond::BrCond Mapping; } TableIcmp32[]; |
| 506 static const size_t TableIcmp32Size; |
| 507 /// @} |
| 508 |
| 509 /// The following table summarizes the logic for lowering the icmp instruction |
| 510 /// for the i64 type. For Eq and Ne, two separate 32-bit comparisons and |
| 511 /// conditional branches are needed. For the other conditions, three separate |
| 512 /// conditional branches are needed. |
| 513 /// {@ |
| 514 static const struct TableIcmp64Type { |
| 515 Cond::BrCond C1, C2, C3; |
| 516 } TableIcmp64[]; |
| 517 static const size_t TableIcmp64Size; |
| 518 /// @} |
| 519 |
| 520 static Cond::BrCond getIcmp32Mapping(InstIcmp::ICond Cond) { |
| 521 size_t Index = static_cast<size_t>(Cond); |
| 522 assert(Index < TableIcmp32Size); |
| 523 return TableIcmp32[Index].Mapping; |
| 524 } |
| 525 |
| 526 static const struct TableTypeX8664AttributesType { |
| 527 Type InVectorElementType; |
| 528 } TableTypeX8664Attributes[]; |
| 529 static const size_t TableTypeX8664AttributesSize; |
| 530 |
| 531 |
| 532 //---------------------------------------------------------------------------- |
| 533 // __ __ __ ______ ______ |
| 534 // /\ \/\ "-.\ \/\ ___\/\__ _\ |
| 535 // \ \ \ \ \-. \ \___ \/_/\ \/ |
| 536 // \ \_\ \_\\"\_\/\_____\ \ \_\ |
| 537 // \/_/\/_/ \/_/\/_____/ \/_/ |
| 538 // |
| 539 //---------------------------------------------------------------------------- |
| 540 using Insts = ::Ice::X86Internal::Insts<TargetX8664>; |
| 541 |
| 542 using TargetLowering = ::Ice::X86Internal::TargetX86Base<TargetX8664>; |
285 using Assembler = X8664::AssemblerX8664; | 543 using Assembler = X8664::AssemblerX8664; |
| 544 |
| 545 /// X86Operand extends the Operand hierarchy. Its subclasses are |
| 546 /// X86OperandMem and VariableSplit. |
| 547 class X86Operand : public ::Ice::Operand { |
| 548 X86Operand() = delete; |
| 549 X86Operand(const X86Operand &) = delete; |
| 550 X86Operand &operator=(const X86Operand &) = delete; |
| 551 |
| 552 public: |
| 553 enum OperandKindX8664 { k__Start = ::Ice::Operand::kTarget, kMem, kSplit }; |
| 554 using ::Ice::Operand::dump; |
| 555 |
| 556 void dump(const Cfg *, Ostream &Str) const override; |
| 557 |
| 558 protected: |
| 559 X86Operand(OperandKindX8664 Kind, Type Ty) |
| 560 : Operand(static_cast<::Ice::Operand::OperandKind>(Kind), Ty) {} |
| 561 }; |
| 562 |
| 563 /// X86OperandMem represents the m64 addressing mode, with optional base and |
| 564 /// index registers, a constant offset, and a fixed shift value for the index |
| 565 /// register. |
| 566 class X86OperandMem : public X86Operand { |
| 567 X86OperandMem() = delete; |
| 568 X86OperandMem(const X86OperandMem &) = delete; |
| 569 X86OperandMem &operator=(const X86OperandMem &) = delete; |
| 570 |
| 571 public: |
| 572 enum SegmentRegisters { |
| 573 DefaultSegment = -1, |
| 574 SegReg_NUM |
| 575 }; |
| 576 static X86OperandMem *create(Cfg *Func, Type Ty, Variable *Base, |
| 577 Constant *Offset, Variable *Index = nullptr, |
| 578 uint16_t Shift = 0, |
| 579 SegmentRegisters SegmentReg = DefaultSegment) { |
| 580 return new (Func->allocate<X86OperandMem>()) |
| 581 X86OperandMem(Func, Ty, Base, Offset, Index, Shift, SegmentReg); |
| 582 } |
| 583 Variable *getBase() const { return Base; } |
| 584 Constant *getOffset() const { return Offset; } |
| 585 Variable *getIndex() const { return Index; } |
| 586 uint16_t getShift() const { return Shift; } |
| 587 SegmentRegisters getSegmentRegister() const { return SegmentReg; } |
| 588 void emitSegmentOverride(Assembler *Asm) const; |
| 589 Address toAsmAddress(Assembler *Asm) const; |
| 590 |
| 591 void emit(const Cfg *Func) const override; |
| 592 using X86Operand::dump; |
| 593 void dump(const Cfg *Func, Ostream &Str) const override; |
| 594 |
| 595 static bool classof(const Operand *Operand) { |
| 596 return Operand->getKind() == static_cast<OperandKind>(kMem); |
| 597 } |
| 598 |
| 599 void setRandomized(bool R) { Randomized = R; } |
| 600 |
| 601 bool getRandomized() const { return Randomized; } |
| 602 |
| 603 private: |
| 604 X86OperandMem(Cfg *Func, Type Ty, Variable *Base, Constant *Offset, |
| 605 Variable *Index, uint16_t Shift, SegmentRegisters SegmentReg); |
| 606 |
| 607 Variable *Base; |
| 608 Constant *Offset; |
| 609 Variable *Index; |
| 610 uint16_t Shift; |
| 611 SegmentRegisters SegmentReg : 16; |
| 612 /// A flag to show if this memory operand is a randomized one. Randomized |
| 613 /// memory operands are generated in |
| 614 /// TargetX86Base::randomizeOrPoolImmediate() |
| 615 bool Randomized; |
| 616 }; |
| 617 |
| 618 /// VariableSplit is a way to treat an f64 memory location as a pair of i32 |
| 619 /// locations (Low and High). This is needed for some cases of the Bitcast |
| 620 /// instruction. Since it's not possible for integer registers to access the |
| 621 /// XMM registers and vice versa, the lowering forces the f64 to be spilled to |
| 622 /// the stack and then accesses through the VariableSplit. |
| 623 // TODO(jpp): remove references to VariableSplit from IceInstX86Base as 64bit |
| 624 // targets can natively handle these. |
| 625 class VariableSplit : public X86Operand { |
| 626 VariableSplit() = delete; |
| 627 VariableSplit(const VariableSplit &) = delete; |
| 628 VariableSplit &operator=(const VariableSplit &) = delete; |
| 629 |
| 630 public: |
| 631 enum Portion { Low, High }; |
| 632 static VariableSplit *create(Cfg *Func, Variable *Var, Portion Part) { |
| 633 return new (Func->allocate<VariableSplit>()) |
| 634 VariableSplit(Func, Var, Part); |
| 635 } |
| 636 int32_t getOffset() const { return Part == High ? 4 : 0; } |
| 637 |
| 638 Address toAsmAddress(const Cfg *Func) const; |
| 639 void emit(const Cfg *Func) const override; |
| 640 using X86Operand::dump; |
| 641 void dump(const Cfg *Func, Ostream &Str) const override; |
| 642 |
| 643 static bool classof(const Operand *Operand) { |
| 644 return Operand->getKind() == static_cast<OperandKind>(kSplit); |
| 645 } |
| 646 |
| 647 private: |
| 648 VariableSplit(Cfg *Func, Variable *Var, Portion Part) |
| 649 : X86Operand(kSplit, IceType_i32), Var(Var), Part(Part) { |
| 650 assert(Var->getType() == IceType_f64); |
| 651 Vars = Func->allocateArrayOf<Variable *>(1); |
| 652 Vars[0] = Var; |
| 653 NumVars = 1; |
| 654 } |
| 655 |
| 656 Variable *Var; |
| 657 Portion Part; |
| 658 }; |
| 659 |
| 660 /// SpillVariable decorates a Variable by linking it to another Variable. |
| 661 /// When stack frame offsets are computed, the SpillVariable is given a |
| 662 /// distinct stack slot only if its linked Variable has a register. If the |
| 663 /// linked Variable has a stack slot, then the Variable and SpillVariable |
| 664 /// share that slot. |
| 665 class SpillVariable : public Variable { |
| 666 SpillVariable() = delete; |
| 667 SpillVariable(const SpillVariable &) = delete; |
| 668 SpillVariable &operator=(const SpillVariable &) = delete; |
| 669 |
| 670 public: |
| 671 static SpillVariable *create(Cfg *Func, Type Ty, SizeT Index) { |
| 672 return new (Func->allocate<SpillVariable>()) SpillVariable(Ty, Index); |
| 673 } |
| 674 const static OperandKind SpillVariableKind = |
| 675 static_cast<OperandKind>(kVariable_Target); |
| 676 static bool classof(const Operand *Operand) { |
| 677 return Operand->getKind() == SpillVariableKind; |
| 678 } |
| 679 void setLinkedTo(Variable *Var) { LinkedTo = Var; } |
| 680 Variable *getLinkedTo() const { return LinkedTo; } |
| 681 // Inherit dump() and emit() from Variable. |
| 682 |
| 683 private: |
| 684 SpillVariable(Type Ty, SizeT Index) |
| 685 : Variable(SpillVariableKind, Ty, Index), LinkedTo(nullptr) {} |
| 686 Variable *LinkedTo; |
| 687 }; |
| 688 |
| 689 // Note: The following data structures are defined in IceInstX8664.cpp. |
| 690 |
| 691 static const struct InstBrAttributesType { |
| 692 Cond::BrCond Opposite; |
| 693 const char *DisplayString; |
| 694 const char *EmitString; |
| 695 } InstBrAttributes[]; |
| 696 |
| 697 static const struct InstCmppsAttributesType { |
| 698 const char *EmitString; |
| 699 } InstCmppsAttributes[]; |
| 700 |
| 701 static const struct TypeAttributesType { |
| 702 const char *CvtString; // i (integer), s (single FP), d (double FP) |
| 703 const char *SdSsString; // ss, sd, or <blank> |
| 704 const char *PackString; // b, w, d, or <blank> |
| 705 const char *WidthString; // b, w, l, q, or <blank> |
| 706 const char *FldString; // s, l, or <blank> |
| 707 } TypeAttributes[]; |
| 708 |
| 709 static const char *InstSegmentRegNames[]; |
| 710 |
| 711 static uint8_t InstSegmentPrefixes[]; |
286 }; | 712 }; |
287 | 713 |
288 } // end of namespace X86Internal | 714 } // end of namespace X86Internal |
289 | 715 |
290 namespace X8664 { | 716 namespace X8664 { |
291 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8664>; | 717 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8664>; |
292 } // end of namespace X8664 | 718 } // end of namespace X8664 |
293 | 719 |
294 } // end of namespace Ice | 720 } // end of namespace Ice |
295 | 721 |
296 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H | 722 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H |
OLD | NEW |