aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineJumpTableInfo.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-25 23:26:13 +0000
committerChris Lattner <sabre@nondot.org>2010-01-25 23:26:13 +0000
commit071c62fad0b25ad4131e7f984173a796c1e63f61 (patch)
treec77e476ec267d26cf4f93ad52dfb5b07fc78b6c5 /include/llvm/CodeGen/MachineJumpTableInfo.h
parentb1e803985d3378538ae9cff7eed4102c002d1e22 (diff)
Rearrange handling of jump tables. Highlights:
1. MachineJumpTableInfo is now created lazily for a function the first time it actually makes a jump table instead of for every function. 2. The encoding of jump table entries is now described by the MachineJumpTableInfo::JTEntryKind enum. This enum is determined by the TLI::getJumpTableEncoding() hook, instead of by lots of code scattered throughout the compiler that "knows" that jump table entries are always 32-bits in pic mode (for example). 3. The size and alignment of jump table entries is now calculated based on their kind, instead of at machinefunction creation time. Future work includes using the EntryKind in more places in the compiler, eliminating other logic that "knows" the layout of jump tables in various situations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94470 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineJumpTableInfo.h')
-rw-r--r--include/llvm/CodeGen/MachineJumpTableInfo.h47
1 files changed, 34 insertions, 13 deletions
diff --git a/include/llvm/CodeGen/MachineJumpTableInfo.h b/include/llvm/CodeGen/MachineJumpTableInfo.h
index 57c65c80a4..d37a5b25fa 100644
--- a/include/llvm/CodeGen/MachineJumpTableInfo.h
+++ b/include/llvm/CodeGen/MachineJumpTableInfo.h
@@ -40,13 +40,41 @@ struct MachineJumpTableEntry {
};
class MachineJumpTableInfo {
- unsigned EntrySize;
- unsigned Alignment;
+public:
+ /// JTEntryKind - This enum indicates how each entry of the jump table is
+ /// represented and emitted.
+ enum JTEntryKind {
+ /// EK_BlockAddress - Each entry is a plain address of block, e.g.:
+ /// .word LBB123
+ EK_BlockAddress,
+
+ /// EK_GPRel32BlockAddress - Each entry is an address of block, encoded
+ /// with a relocation as gp-relative, e.g.:
+ /// .gprel32 LBB123
+ EK_GPRel32BlockAddress,
+
+ /// EK_LabelDifference32 - Each entry is the address of the block minus
+ /// the address of the jump table. This is used for PIC jump tables where
+ /// gprel32 is not supported. e.g.:
+ /// .word LBB123 - LJTI1_2
+ /// If the .set directive is supported, this is emitted as:
+ /// .set L4_5_set_123, LBB123 - LJTI1_2
+ /// .word L4_5_set_123
+ EK_LabelDifference32
+ };
+private:
+ JTEntryKind EntryKind;
std::vector<MachineJumpTableEntry> JumpTables;
public:
- MachineJumpTableInfo(unsigned Size, unsigned Align)
- : EntrySize(Size), Alignment(Align) {}
+ MachineJumpTableInfo(JTEntryKind Kind): EntryKind(Kind) {}
+ JTEntryKind getEntryKind() const { return EntryKind; }
+
+ /// getEntrySize - Return the size of each entry in the jump table.
+ unsigned getEntrySize(const TargetData &TD) const;
+ /// getEntryAlignment - Return the alignment of each entry in the jump table.
+ unsigned getEntryAlignment(const TargetData &TD) const;
+
/// getJumpTableIndex - Create a new jump table or return an existing one.
///
unsigned getJumpTableIndex(const std::vector<MachineBasicBlock*> &DestBBs);
@@ -59,8 +87,8 @@ public:
return JumpTables;
}
- /// RemoveJumpTable - Mark the specific index as being dead. This will cause
- /// it to not be emitted.
+ /// RemoveJumpTable - Mark the specific index as being dead. This will
+ /// prevent it from being emitted.
void RemoveJumpTable(unsigned Idx) {
JumpTables[Idx].MBBs.clear();
}
@@ -74,13 +102,6 @@ public:
bool ReplaceMBBInJumpTable(unsigned Idx, MachineBasicBlock *Old,
MachineBasicBlock *New);
- /// getEntrySize - Returns the size of an individual field in a jump table.
- ///
- unsigned getEntrySize() const { return EntrySize; }
-
- /// getAlignment - returns the target's preferred alignment for jump tables
- unsigned getAlignment() const { return Alignment; }
-
/// print - Used by the MachineFunction printer to print information about
/// jump tables. Implemented in MachineFunction.cpp
///