| OLD | NEW |
| 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// | 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// |
| 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 implements the TargetLoweringX8632 class, which | 10 // This file implements the TargetLoweringX8632 class, which |
| 11 // consists almost entirely of the lowering sequence for each | 11 // consists almost entirely of the lowering sequence for each |
| 12 // high-level instruction. It also implements | 12 // high-level instruction. It also implements |
| 13 // TargetX8632Fast::postLower() which does the simplest possible | 13 // TargetX8632Fast::postLower() which does the simplest possible |
| 14 // register allocation for the "fast" target. | 14 // register allocation for the "fast" target. |
| 15 // | 15 // |
| 16 //===----------------------------------------------------------------------===// | 16 //===----------------------------------------------------------------------===// |
| 17 | 17 |
| 18 #include "IceDefs.h" | 18 #include "IceDefs.h" |
| 19 #include "IceCfg.h" | 19 #include "IceCfg.h" |
| 20 #include "IceCfgNode.h" | 20 #include "IceCfgNode.h" |
| 21 #include "IceClFlags.h" | 21 #include "IceClFlags.h" |
| 22 #include "IceInstX8632.h" | 22 #include "IceInstX8632.h" |
| 23 #include "IceOperand.h" | 23 #include "IceOperand.h" |
| 24 #include "IceTargetLoweringX8632.def" | 24 #include "IceTargetLoweringX8632.def" |
| 25 #include "IceTargetLoweringX8632.h" | 25 #include "IceTargetLoweringX8632.h" |
| 26 #include "llvm/ADT/DenseMap.h" | 26 #include "llvm/ADT/DenseMap.h" |
| 27 #include "llvm/Support/MathExtras.h" |
| 27 #include "llvm/Support/CommandLine.h" | 28 #include "llvm/Support/CommandLine.h" |
| 28 | 29 |
| 29 #include <strings.h> | |
| 30 | |
| 31 namespace Ice { | 30 namespace Ice { |
| 32 | 31 |
| 33 namespace { | 32 namespace { |
| 34 | 33 |
| 35 // The following table summarizes the logic for lowering the fcmp | 34 // The following table summarizes the logic for lowering the fcmp |
| 36 // instruction. There is one table entry for each of the 16 conditions. | 35 // instruction. There is one table entry for each of the 16 conditions. |
| 37 // | 36 // |
| 38 // The first four columns describe the case when the operands are | 37 // The first four columns describe the case when the operands are |
| 39 // floating point scalar values. A comment in lowerFcmp() describes the | 38 // floating point scalar values. A comment in lowerFcmp() describes the |
| 40 // lowering template. In the most general case, there is a compare | 39 // lowering template. In the most general case, there is a compare |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 // Sort the variables into buckets according to the log of their width | 549 // Sort the variables into buckets according to the log of their width |
| 551 // in bytes. | 550 // in bytes. |
| 552 const SizeT NumBuckets = | 551 const SizeT NumBuckets = |
| 553 X86_LOG2_OF_MAX_STACK_SLOT_SIZE - X86_LOG2_OF_MIN_STACK_SLOT_SIZE + 1; | 552 X86_LOG2_OF_MAX_STACK_SLOT_SIZE - X86_LOG2_OF_MIN_STACK_SLOT_SIZE + 1; |
| 554 VarList Buckets[NumBuckets]; | 553 VarList Buckets[NumBuckets]; |
| 555 | 554 |
| 556 for (VarList::const_iterator I = Source.begin(), E = Source.end(); I != E; | 555 for (VarList::const_iterator I = Source.begin(), E = Source.end(); I != E; |
| 557 ++I) { | 556 ++I) { |
| 558 Variable *Var = *I; | 557 Variable *Var = *I; |
| 559 uint32_t NaturalAlignment = typeWidthInBytesOnStack(Var->getType()); | 558 uint32_t NaturalAlignment = typeWidthInBytesOnStack(Var->getType()); |
| 560 SizeT LogNaturalAlignment = ffs(NaturalAlignment) - 1; | 559 SizeT LogNaturalAlignment = llvm::findFirstSet(NaturalAlignment); |
| 561 assert(LogNaturalAlignment >= X86_LOG2_OF_MIN_STACK_SLOT_SIZE); | 560 assert(LogNaturalAlignment >= X86_LOG2_OF_MIN_STACK_SLOT_SIZE); |
| 562 assert(LogNaturalAlignment <= X86_LOG2_OF_MAX_STACK_SLOT_SIZE); | 561 assert(LogNaturalAlignment <= X86_LOG2_OF_MAX_STACK_SLOT_SIZE); |
| 563 SizeT BucketIndex = LogNaturalAlignment - X86_LOG2_OF_MIN_STACK_SLOT_SIZE; | 562 SizeT BucketIndex = LogNaturalAlignment - X86_LOG2_OF_MIN_STACK_SLOT_SIZE; |
| 564 Buckets[BucketIndex].push_back(Var); | 563 Buckets[BucketIndex].push_back(Var); |
| 565 } | 564 } |
| 566 | 565 |
| 567 for (SizeT I = 0, E = NumBuckets; I < E; ++I) { | 566 for (SizeT I = 0, E = NumBuckets; I < E; ++I) { |
| 568 VarList &List = Buckets[NumBuckets - I - 1]; | 567 VarList &List = Buckets[NumBuckets - I - 1]; |
| 569 Dest.insert(Dest.end(), List.begin(), List.end()); | 568 Dest.insert(Dest.end(), List.begin(), List.end()); |
| 570 } | 569 } |
| (...skipping 3890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4461 Str << "\t.align\t" << Align << "\n"; | 4460 Str << "\t.align\t" << Align << "\n"; |
| 4462 Str << MangledName << ":\n"; | 4461 Str << MangledName << ":\n"; |
| 4463 for (SizeT i = 0; i < Size; ++i) { | 4462 for (SizeT i = 0; i < Size; ++i) { |
| 4464 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; | 4463 Str << "\t.byte\t" << (((unsigned)Data[i]) & 0xff) << "\n"; |
| 4465 } | 4464 } |
| 4466 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; | 4465 Str << "\t.size\t" << MangledName << ", " << Size << "\n"; |
| 4467 } | 4466 } |
| 4468 } | 4467 } |
| 4469 | 4468 |
| 4470 } // end of namespace Ice | 4469 } // end of namespace Ice |
| OLD | NEW |