Skip to content

[llvm] annotate interfaces in AsmParser, BinaryFormat, Bitcode, and Bitstream libraries for DLL export #141794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 30 additions & 29 deletions llvm/include/llvm/AsmParser/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
#include <memory>
#include <optional>

Expand Down Expand Up @@ -44,9 +45,9 @@ typedef llvm::function_ref<std::optional<std::string>(StringRef, StringRef)>
/// \param Context Context in which to allocate globals info.
/// \param Slots The optional slot mapping that will be initialized during
/// parsing.
std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, SMDiagnostic &Err,
LLVMContext &Context,
SlotMapping *Slots = nullptr);
LLVM_ABI std::unique_ptr<Module>
parseAssemblyFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
SlotMapping *Slots = nullptr);

/// The function is a secondary interface to the LLVM Assembly Parser. It parses
/// an ASCII string that (presumably) contains LLVM Assembly code. It returns a
Expand All @@ -59,10 +60,9 @@ std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, SMDiagnostic &Err,
/// \param Context Context in which to allocate globals info.
/// \param Slots The optional slot mapping that will be initialized during
/// parsing.
std::unique_ptr<Module> parseAssemblyString(StringRef AsmString,
SMDiagnostic &Err,
LLVMContext &Context,
SlotMapping *Slots = nullptr);
LLVM_ABI std::unique_ptr<Module>
parseAssemblyString(StringRef AsmString, SMDiagnostic &Err,
LLVMContext &Context, SlotMapping *Slots = nullptr);

/// Holds the Module and ModuleSummaryIndex returned by the interfaces
/// that parse both.
Expand All @@ -84,15 +84,15 @@ struct ParsedModuleAndIndex {
/// \param Slots The optional slot mapping that will be initialized during
/// parsing.
/// \param DataLayoutCallback Override datalayout in the llvm assembly.
ParsedModuleAndIndex parseAssemblyFileWithIndex(
LLVM_ABI ParsedModuleAndIndex parseAssemblyFileWithIndex(
StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
SlotMapping *Slots = nullptr,
DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
return std::nullopt;
});

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

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

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

/// parseAssemblyFile and parseAssemblyString are wrappers around this function.
Expand All @@ -125,7 +125,7 @@ parseSummaryIndexAssemblyString(StringRef AsmString, SMDiagnostic &Err);
/// \param Slots The optional slot mapping that will be initialized during
/// parsing.
/// \param DataLayoutCallback Override datalayout in the llvm assembly.
std::unique_ptr<Module> parseAssembly(
LLVM_ABI std::unique_ptr<Module> parseAssembly(
MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context,
SlotMapping *Slots = nullptr,
DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
Expand All @@ -140,18 +140,17 @@ std::unique_ptr<Module> parseAssembly(
/// parsing.
///
/// parseAssemblyFileWithIndex is a wrapper around this function.
ParsedModuleAndIndex parseAssemblyWithIndex(MemoryBufferRef F,
SMDiagnostic &Err,
LLVMContext &Context,
SlotMapping *Slots = nullptr);
LLVM_ABI ParsedModuleAndIndex
parseAssemblyWithIndex(MemoryBufferRef F, SMDiagnostic &Err,
LLVMContext &Context, SlotMapping *Slots = nullptr);

/// Parse LLVM Assembly for summary index from a MemoryBuffer.
///
/// \param F The MemoryBuffer containing assembly with summary
/// \param Err Error result info.
///
/// parseSummaryIndexAssemblyFile is a wrapper around this function.
std::unique_ptr<ModuleSummaryIndex>
LLVM_ABI std::unique_ptr<ModuleSummaryIndex>
parseSummaryIndexAssembly(MemoryBufferRef F, SMDiagnostic &Err);

/// This function is the low-level interface to the LLVM Assembly Parser.
Expand All @@ -167,7 +166,7 @@ parseSummaryIndexAssembly(MemoryBufferRef F, SMDiagnostic &Err);
/// parsing.
/// \return true on error.
/// \param DataLayoutCallback Override datalayout in the llvm assembly.
bool parseAssemblyInto(
LLVM_ABI bool parseAssemblyInto(
MemoryBufferRef F, Module *M, ModuleSummaryIndex *Index, SMDiagnostic &Err,
SlotMapping *Slots = nullptr,
DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
Expand All @@ -182,16 +181,17 @@ bool parseAssemblyInto(
/// \param Slots The optional slot mapping that will restore the parsing state
/// of the module.
/// \return null on error.
Constant *parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M,
const SlotMapping *Slots = nullptr);
LLVM_ABI Constant *parseConstantValue(StringRef Asm, SMDiagnostic &Err,
const Module &M,
const SlotMapping *Slots = nullptr);

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

/// Parse a string \p Asm that starts with a type.
/// \p Read[out] gives the number of characters that have been read to parse
Expand All @@ -200,13 +200,14 @@ Type *parseType(StringRef Asm, SMDiagnostic &Err, const Module &M,
/// \param Slots The optional slot mapping that will restore the parsing state
/// of the module.
/// \return null on error.
Type *parseTypeAtBeginning(StringRef Asm, unsigned &Read, SMDiagnostic &Err,
const Module &M, const SlotMapping *Slots = nullptr);

DIExpression *parseDIExpressionBodyAtBeginning(StringRef Asm, unsigned &Read,
SMDiagnostic &Err,
const Module &M,
const SlotMapping *Slots);
LLVM_ABI Type *parseTypeAtBeginning(StringRef Asm, unsigned &Read,
SMDiagnostic &Err, const Module &M,
const SlotMapping *Slots = nullptr);

LLVM_ABI DIExpression *
parseDIExpressionBodyAtBeginning(StringRef Asm, unsigned &Read,
SMDiagnostic &Err, const Module &M,
const SlotMapping *Slots);

} // End llvm namespace

Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/BinaryFormat/AMDGPUMetadataVerifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/MsgPackReader.h"
#include "llvm/Support/Compiler.h"

#include <cstddef>
#include <optional>
Expand Down Expand Up @@ -69,7 +70,7 @@ class MetadataVerifier {
/// Verify given HSA metadata.
///
/// \returns True when successful, false when metadata is invalid.
bool verify(msgpack::DocNode &HSAMetadataRoot);
LLVM_ABI bool verify(msgpack::DocNode &HSAMetadataRoot);
};

} // end namespace V3
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/BinaryFormat/COFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifndef LLVM_BINARYFORMAT_COFF_H
#define LLVM_BINARYFORMAT_COFF_H

#include "llvm/Support/Compiler.h"
#include "llvm/Support/DataTypes.h"
#include <cassert>

Expand Down Expand Up @@ -851,7 +852,7 @@ inline bool isReservedSectionNumber(int32_t SectionNumber) {

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

} // End namespace COFF.
} // End namespace llvm.
Expand Down
25 changes: 13 additions & 12 deletions llvm/include/llvm/BinaryFormat/DXContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define LLVM_BINARYFORMAT_DXCONTAINER_H

#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/TargetParser/Triple.h"
Expand Down Expand Up @@ -59,7 +60,7 @@ struct ShaderHash {
uint32_t Flags; // dxbc::HashFlags
uint8_t Digest[16];

bool isPopulated();
LLVM_ABI bool isPopulated();

void swapBytes() { sys::swapByteOrder(Flags); }
};
Expand Down Expand Up @@ -173,7 +174,7 @@ enum class RootParameterType : uint32_t {
#include "DXContainerConstants.def"
};

ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes();
LLVM_ABI ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes();

#define DESCRIPTOR_RANGE(Val, Enum) Enum = Val,
enum class DescriptorRangeType : uint32_t {
Expand All @@ -197,7 +198,7 @@ enum class ShaderVisibility : uint32_t {
#include "DXContainerConstants.def"
};

ArrayRef<EnumEntry<ShaderVisibility>> getShaderVisibility();
LLVM_ABI ArrayRef<EnumEntry<ShaderVisibility>> getShaderVisibility();

#define SHADER_VISIBILITY(Val, Enum) \
case Val: \
Expand Down Expand Up @@ -229,7 +230,7 @@ enum class SamplersBorderColor : uint32_t {
#include "DXContainerConstants.def"
};

PartType parsePartType(StringRef S);
LLVM_ABI PartType parsePartType(StringRef S);

struct VertexPSVInfo {
uint8_t OutputPositionPresent;
Expand Down Expand Up @@ -360,35 +361,35 @@ enum class SemanticKind : uint8_t {
#include "DXContainerConstants.def"
};

ArrayRef<EnumEntry<SemanticKind>> getSemanticKinds();
LLVM_ABI ArrayRef<EnumEntry<SemanticKind>> getSemanticKinds();

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

ArrayRef<EnumEntry<ComponentType>> getComponentTypes();
LLVM_ABI ArrayRef<EnumEntry<ComponentType>> getComponentTypes();

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

ArrayRef<EnumEntry<InterpolationMode>> getInterpolationModes();
LLVM_ABI ArrayRef<EnumEntry<InterpolationMode>> getInterpolationModes();

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

ArrayRef<EnumEntry<ResourceType>> getResourceTypes();
LLVM_ABI ArrayRef<EnumEntry<ResourceType>> getResourceTypes();

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

ArrayRef<EnumEntry<ResourceKind>> getResourceKinds();
LLVM_ABI ArrayRef<EnumEntry<ResourceKind>> getResourceKinds();

#define RESOURCE_FLAG(Index, Enum) bool Enum = false;
struct ResourceFlags {
Expand Down Expand Up @@ -555,21 +556,21 @@ enum class SigMinPrecision : uint32_t {
#include "DXContainerConstants.def"
};

ArrayRef<EnumEntry<SigMinPrecision>> getSigMinPrecisions();
LLVM_ABI ArrayRef<EnumEntry<SigMinPrecision>> getSigMinPrecisions();

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

ArrayRef<EnumEntry<D3DSystemValue>> getD3DSystemValues();
LLVM_ABI ArrayRef<EnumEntry<D3DSystemValue>> getD3DSystemValues();

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

ArrayRef<EnumEntry<SigComponentType>> getSigComponentTypes();
LLVM_ABI ArrayRef<EnumEntry<SigComponentType>> getSigComponentTypes();

struct ProgramSignatureHeader {
uint32_t ParamCount;
Expand Down
Loading
Loading