Skip to content

Commit ef37d9c

Browse files
committed
[DataLayout] Refactor parseSpecification
1 parent 6543bd7 commit ef37d9c

File tree

11 files changed

+338
-357
lines changed

11 files changed

+338
-357
lines changed

llvm/include/llvm/IR/DataLayout.h

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,6 @@ class DataLayout {
115115
// FIXME: `unsigned char` truncates the value parsed by `parseSpecifier`.
116116
SmallVector<unsigned char, 8> LegalIntWidths;
117117

118-
/// Type specifier used by some internal functions.
119-
enum class TypeSpecifier {
120-
Integer = 'i',
121-
Float = 'f',
122-
Vector = 'v',
123-
Aggregate = 'a'
124-
};
125-
126118
/// Primitive type specifications. Sorted and uniqued by type bit width.
127119
SmallVector<PrimitiveSpec, 6> IntSpecs;
128120
SmallVector<PrimitiveSpec, 4> FloatSpecs;
@@ -145,28 +137,35 @@ class DataLayout {
145137
/// well-defined bitwise representation.
146138
SmallVector<unsigned, 8> NonIntegralAddressSpaces;
147139

148-
/// Attempts to set the specification for the given type.
149-
/// Returns an error description on failure.
150-
Error setPrimitiveSpec(TypeSpecifier Specifier, uint32_t BitWidth,
151-
Align ABIAlign, Align PrefAlign);
140+
/// Sets or updates the specification for the given primitive type.
141+
void setPrimitiveSpec(char Specifier, uint32_t BitWidth, Align ABIAlign,
142+
Align PrefAlign);
152143

153144
/// Searches for a pointer specification that matches the given address space.
154145
/// Returns the default address space specification if not found.
155146
const PointerSpec &getPointerSpec(uint32_t AddrSpace) const;
156147

157-
/// Attempts to set the specification for pointer in the given address space.
158-
/// Returns an error description on failure.
159-
Error setPointerSpec(uint32_t AddrSpace, uint32_t BitWidth, Align ABIAlign,
160-
Align PrefAlign, uint32_t IndexBitWidth);
148+
/// Sets or updates the specification for pointer in the given address space.
149+
void setPointerSpec(uint32_t AddrSpace, uint32_t BitWidth, Align ABIAlign,
150+
Align PrefAlign, uint32_t IndexBitWidth);
161151

162152
/// Internal helper to get alignment for integer of given bitwidth.
163153
Align getIntegerAlignment(uint32_t BitWidth, bool abi_or_pref) const;
164154

165155
/// Internal helper method that returns requested alignment for type.
166156
Align getAlignment(Type *Ty, bool abi_or_pref) const;
167157

158+
/// Attempts to parse primitive specification ('i', 'f', or 'v').
159+
Error parsePrimitiveSpec(StringRef SpecStr);
160+
161+
/// Attempts to parse aggregate specification ('a').
162+
Error parseAggregateSpec(StringRef SpecStr);
163+
164+
/// Attempts to parse pointer specification ('p').
165+
Error parsePointerSpec(StringRef SpecStr);
166+
168167
/// Attempts to parse a single specification.
169-
Error parseSpecification(StringRef Specification);
168+
Error parseSpecification(StringRef SpecStr);
170169

171170
/// Attempts to parse a data layout string.
172171
Error parseLayoutString(StringRef LayoutString);

0 commit comments

Comments
 (0)