Skip to content

Commit 515859b

Browse files
committed
[llvm] IDS auto codemod for AsmParser, BinaryFormat, Bitcode, and Bitstream libraries
1 parent 764ae04 commit 515859b

File tree

18 files changed

+214
-198
lines changed

18 files changed

+214
-198
lines changed

llvm/include/llvm/AsmParser/Parser.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_ASMPARSER_PARSER_H
1414
#define LLVM_ASMPARSER_PARSER_H
1515

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/ADT/STLFunctionalExtras.h"
1718
#include "llvm/ADT/StringRef.h"
1819
#include <memory>
@@ -44,7 +45,7 @@ typedef llvm::function_ref<std::optional<std::string>(StringRef, StringRef)>
4445
/// \param Context Context in which to allocate globals info.
4546
/// \param Slots The optional slot mapping that will be initialized during
4647
/// parsing.
47-
std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, SMDiagnostic &Err,
48+
LLVM_ABI std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, SMDiagnostic &Err,
4849
LLVMContext &Context,
4950
SlotMapping *Slots = nullptr);
5051

@@ -59,7 +60,7 @@ std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, SMDiagnostic &Err,
5960
/// \param Context Context in which to allocate globals info.
6061
/// \param Slots The optional slot mapping that will be initialized during
6162
/// parsing.
62-
std::unique_ptr<Module> parseAssemblyString(StringRef AsmString,
63+
LLVM_ABI std::unique_ptr<Module> parseAssemblyString(StringRef AsmString,
6364
SMDiagnostic &Err,
6465
LLVMContext &Context,
6566
SlotMapping *Slots = nullptr);
@@ -84,15 +85,15 @@ struct ParsedModuleAndIndex {
8485
/// \param Slots The optional slot mapping that will be initialized during
8586
/// parsing.
8687
/// \param DataLayoutCallback Override datalayout in the llvm assembly.
87-
ParsedModuleAndIndex parseAssemblyFileWithIndex(
88+
LLVM_ABI ParsedModuleAndIndex parseAssemblyFileWithIndex(
8889
StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
8990
SlotMapping *Slots = nullptr,
9091
DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
9192
return std::nullopt;
9293
});
9394

9495
/// Only for use in llvm-as for testing; this does not produce a valid module.
95-
ParsedModuleAndIndex parseAssemblyFileWithIndexNoUpgradeDebugInfo(
96+
LLVM_ABI ParsedModuleAndIndex parseAssemblyFileWithIndexNoUpgradeDebugInfo(
9697
StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
9798
SlotMapping *Slots, DataLayoutCallbackTy DataLayoutCallback);
9899

@@ -104,7 +105,7 @@ ParsedModuleAndIndex parseAssemblyFileWithIndexNoUpgradeDebugInfo(
104105
/// Parse LLVM Assembly Index from a file
105106
/// \param Filename The name of the file to parse
106107
/// \param Err Error result info.
107-
std::unique_ptr<ModuleSummaryIndex>
108+
LLVM_ABI std::unique_ptr<ModuleSummaryIndex>
108109
parseSummaryIndexAssemblyFile(StringRef Filename, SMDiagnostic &Err);
109110

110111
/// The function is a secondary interface to the LLVM Assembly Parser. It parses
@@ -115,7 +116,7 @@ parseSummaryIndexAssemblyFile(StringRef Filename, SMDiagnostic &Err);
115116
/// Parse LLVM Assembly from a string
116117
/// \param AsmString The string containing assembly
117118
/// \param Err Error result info.
118-
std::unique_ptr<ModuleSummaryIndex>
119+
LLVM_ABI std::unique_ptr<ModuleSummaryIndex>
119120
parseSummaryIndexAssemblyString(StringRef AsmString, SMDiagnostic &Err);
120121

121122
/// parseAssemblyFile and parseAssemblyString are wrappers around this function.
@@ -125,7 +126,7 @@ parseSummaryIndexAssemblyString(StringRef AsmString, SMDiagnostic &Err);
125126
/// \param Slots The optional slot mapping that will be initialized during
126127
/// parsing.
127128
/// \param DataLayoutCallback Override datalayout in the llvm assembly.
128-
std::unique_ptr<Module> parseAssembly(
129+
LLVM_ABI std::unique_ptr<Module> parseAssembly(
129130
MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context,
130131
SlotMapping *Slots = nullptr,
131132
DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
@@ -140,7 +141,7 @@ std::unique_ptr<Module> parseAssembly(
140141
/// parsing.
141142
///
142143
/// parseAssemblyFileWithIndex is a wrapper around this function.
143-
ParsedModuleAndIndex parseAssemblyWithIndex(MemoryBufferRef F,
144+
LLVM_ABI ParsedModuleAndIndex parseAssemblyWithIndex(MemoryBufferRef F,
144145
SMDiagnostic &Err,
145146
LLVMContext &Context,
146147
SlotMapping *Slots = nullptr);
@@ -151,7 +152,7 @@ ParsedModuleAndIndex parseAssemblyWithIndex(MemoryBufferRef F,
151152
/// \param Err Error result info.
152153
///
153154
/// parseSummaryIndexAssemblyFile is a wrapper around this function.
154-
std::unique_ptr<ModuleSummaryIndex>
155+
LLVM_ABI std::unique_ptr<ModuleSummaryIndex>
155156
parseSummaryIndexAssembly(MemoryBufferRef F, SMDiagnostic &Err);
156157

157158
/// This function is the low-level interface to the LLVM Assembly Parser.
@@ -167,7 +168,7 @@ parseSummaryIndexAssembly(MemoryBufferRef F, SMDiagnostic &Err);
167168
/// parsing.
168169
/// \return true on error.
169170
/// \param DataLayoutCallback Override datalayout in the llvm assembly.
170-
bool parseAssemblyInto(
171+
LLVM_ABI bool parseAssemblyInto(
171172
MemoryBufferRef F, Module *M, ModuleSummaryIndex *Index, SMDiagnostic &Err,
172173
SlotMapping *Slots = nullptr,
173174
DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
@@ -182,15 +183,15 @@ bool parseAssemblyInto(
182183
/// \param Slots The optional slot mapping that will restore the parsing state
183184
/// of the module.
184185
/// \return null on error.
185-
Constant *parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M,
186+
LLVM_ABI Constant *parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M,
186187
const SlotMapping *Slots = nullptr);
187188

188189
/// Parse a type in the given string.
189190
///
190191
/// \param Slots The optional slot mapping that will restore the parsing state
191192
/// of the module.
192193
/// \return null on error.
193-
Type *parseType(StringRef Asm, SMDiagnostic &Err, const Module &M,
194+
LLVM_ABI Type *parseType(StringRef Asm, SMDiagnostic &Err, const Module &M,
194195
const SlotMapping *Slots = nullptr);
195196

196197
/// Parse a string \p Asm that starts with a type.
@@ -200,10 +201,10 @@ Type *parseType(StringRef Asm, SMDiagnostic &Err, const Module &M,
200201
/// \param Slots The optional slot mapping that will restore the parsing state
201202
/// of the module.
202203
/// \return null on error.
203-
Type *parseTypeAtBeginning(StringRef Asm, unsigned &Read, SMDiagnostic &Err,
204+
LLVM_ABI Type *parseTypeAtBeginning(StringRef Asm, unsigned &Read, SMDiagnostic &Err,
204205
const Module &M, const SlotMapping *Slots = nullptr);
205206

206-
DIExpression *parseDIExpressionBodyAtBeginning(StringRef Asm, unsigned &Read,
207+
LLVM_ABI DIExpression *parseDIExpressionBodyAtBeginning(StringRef Asm, unsigned &Read,
207208
SMDiagnostic &Err,
208209
const Module &M,
209210
const SlotMapping *Slots);

llvm/include/llvm/BinaryFormat/AMDGPUMetadataVerifier.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
1717
#define LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
1818

19+
#include "llvm/Support/Compiler.h"
1920
#include "llvm/ADT/STLFunctionalExtras.h"
2021
#include "llvm/ADT/StringRef.h"
2122
#include "llvm/BinaryFormat/MsgPackReader.h"
@@ -69,7 +70,7 @@ class MetadataVerifier {
6970
/// Verify given HSA metadata.
7071
///
7172
/// \returns True when successful, false when metadata is invalid.
72-
bool verify(msgpack::DocNode &HSAMetadataRoot);
73+
LLVM_ABI bool verify(msgpack::DocNode &HSAMetadataRoot);
7374
};
7475

7576
} // end namespace V3

llvm/include/llvm/BinaryFormat/COFF.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#ifndef LLVM_BINARYFORMAT_COFF_H
2323
#define LLVM_BINARYFORMAT_COFF_H
2424

25+
#include "llvm/Support/Compiler.h"
2526
#include "llvm/Support/DataTypes.h"
2627
#include <cassert>
2728

@@ -851,7 +852,7 @@ inline bool isReservedSectionNumber(int32_t SectionNumber) {
851852

852853
/// Encode section name based on string table offset.
853854
/// The size of Out must be at least COFF::NameSize.
854-
bool encodeSectionName(char *Out, uint64_t Offset);
855+
LLVM_ABI bool encodeSectionName(char *Out, uint64_t Offset);
855856

856857
} // End namespace COFF.
857858
} // End namespace llvm.

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_BINARYFORMAT_DXCONTAINER_H
1414
#define LLVM_BINARYFORMAT_DXCONTAINER_H
1515

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/ADT/StringRef.h"
1718
#include "llvm/Support/Error.h"
1819
#include "llvm/Support/SwapByteOrder.h"
@@ -59,7 +60,7 @@ struct ShaderHash {
5960
uint32_t Flags; // dxbc::HashFlags
6061
uint8_t Digest[16];
6162

62-
bool isPopulated();
63+
LLVM_ABI bool isPopulated();
6364

6465
void swapBytes() { sys::swapByteOrder(Flags); }
6566
};
@@ -168,7 +169,7 @@ enum class RootParameterType : uint32_t {
168169
#include "DXContainerConstants.def"
169170
};
170171

171-
ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes();
172+
LLVM_ABI ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes();
172173

173174
#define ROOT_PARAMETER(Val, Enum) \
174175
case Val: \
@@ -185,7 +186,7 @@ enum class ShaderVisibility : uint32_t {
185186
#include "DXContainerConstants.def"
186187
};
187188

188-
ArrayRef<EnumEntry<ShaderVisibility>> getShaderVisibility();
189+
LLVM_ABI ArrayRef<EnumEntry<ShaderVisibility>> getShaderVisibility();
189190

190191
#define SHADER_VISIBILITY(Val, Enum) \
191192
case Val: \
@@ -197,7 +198,7 @@ inline bool isValidShaderVisibility(uint32_t V) {
197198
return false;
198199
}
199200

200-
PartType parsePartType(StringRef S);
201+
LLVM_ABI PartType parsePartType(StringRef S);
201202

202203
struct VertexPSVInfo {
203204
uint8_t OutputPositionPresent;
@@ -328,35 +329,35 @@ enum class SemanticKind : uint8_t {
328329
#include "DXContainerConstants.def"
329330
};
330331

331-
ArrayRef<EnumEntry<SemanticKind>> getSemanticKinds();
332+
LLVM_ABI ArrayRef<EnumEntry<SemanticKind>> getSemanticKinds();
332333

333334
#define COMPONENT_TYPE(Val, Enum) Enum = Val,
334335
enum class ComponentType : uint8_t {
335336
#include "DXContainerConstants.def"
336337
};
337338

338-
ArrayRef<EnumEntry<ComponentType>> getComponentTypes();
339+
LLVM_ABI ArrayRef<EnumEntry<ComponentType>> getComponentTypes();
339340

340341
#define INTERPOLATION_MODE(Val, Enum) Enum = Val,
341342
enum class InterpolationMode : uint8_t {
342343
#include "DXContainerConstants.def"
343344
};
344345

345-
ArrayRef<EnumEntry<InterpolationMode>> getInterpolationModes();
346+
LLVM_ABI ArrayRef<EnumEntry<InterpolationMode>> getInterpolationModes();
346347

347348
#define RESOURCE_TYPE(Val, Enum) Enum = Val,
348349
enum class ResourceType : uint32_t {
349350
#include "DXContainerConstants.def"
350351
};
351352

352-
ArrayRef<EnumEntry<ResourceType>> getResourceTypes();
353+
LLVM_ABI ArrayRef<EnumEntry<ResourceType>> getResourceTypes();
353354

354355
#define RESOURCE_KIND(Val, Enum) Enum = Val,
355356
enum class ResourceKind : uint32_t {
356357
#include "DXContainerConstants.def"
357358
};
358359

359-
ArrayRef<EnumEntry<ResourceKind>> getResourceKinds();
360+
LLVM_ABI ArrayRef<EnumEntry<ResourceKind>> getResourceKinds();
360361

361362
#define RESOURCE_FLAG(Index, Enum) bool Enum = false;
362363
struct ResourceFlags {
@@ -523,21 +524,21 @@ enum class SigMinPrecision : uint32_t {
523524
#include "DXContainerConstants.def"
524525
};
525526

526-
ArrayRef<EnumEntry<SigMinPrecision>> getSigMinPrecisions();
527+
LLVM_ABI ArrayRef<EnumEntry<SigMinPrecision>> getSigMinPrecisions();
527528

528529
#define D3D_SYSTEM_VALUE(Val, Enum) Enum = Val,
529530
enum class D3DSystemValue : uint32_t {
530531
#include "DXContainerConstants.def"
531532
};
532533

533-
ArrayRef<EnumEntry<D3DSystemValue>> getD3DSystemValues();
534+
LLVM_ABI ArrayRef<EnumEntry<D3DSystemValue>> getD3DSystemValues();
534535

535536
#define COMPONENT_TYPE(Val, Enum) Enum = Val,
536537
enum class SigComponentType : uint32_t {
537538
#include "DXContainerConstants.def"
538539
};
539540

540-
ArrayRef<EnumEntry<SigComponentType>> getSigComponentTypes();
541+
LLVM_ABI ArrayRef<EnumEntry<SigComponentType>> getSigComponentTypes();
541542

542543
struct ProgramSignatureHeader {
543544
uint32_t ParamCount;

0 commit comments

Comments
 (0)