Skip to content
Open
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
4 changes: 3 additions & 1 deletion llvm/bindings/ocaml/llvm/llvm_ocaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ value llvm_dispose_context(value C) {
}

/* unit -> llcontext */
value llvm_global_context(value Unit) { return to_val(LLVMGetGlobalContext()); }
value llvm_global_context(value Unit) {
return to_val(getGlobalContextForCAPI());
}

/* llcontext -> string -> int */
value llvm_mdkind_id(value C, value Name) {
Expand Down
35 changes: 35 additions & 0 deletions llvm/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,41 @@ Changes to the C API

* Add `LLVMGetOrInsertFunction` to get or insert a function, replacing the combination of `LLVMGetNamedFunction` and `LLVMAddFunction`.
* Allow `LLVMGetVolatile` to work with any kind of Instruction.
* Functions working on the global context have been deprecated. Use the
functions that work on a specific context instead.

* `LLVMGetGlobalContext` -> use `LLVMContextCreate` context instead
* `LLVMInt1Type` -> `LLVMInt1TypeInContext`
* `LLVMInt8Type` -> `LLVMInt8TypeInContext`
* `LLVMInt16Type` -> `LLVMInt16TypeInContext`
* `LLVMInt32Type` -> `LLVMInt32TypeInContext`
* `LLVMInt64Type` -> `LLVMInt64TypeInContext`
* `LLVMInt128Type` -> `LLVMInt128TypeInContext`
* `LLVMIntType` -> `LLVMIntTypeInContext`
* `LLVMHalfType` -> `LLVMHalfTypeInContext`
* `LLVMBFloatType` -> `LLVMBFloatTypeInContext`
* `LLVMFloatType` -> `LLVMFloatTypeInContext`
* `LLVMDoubleType` -> `LLVMDoubleTypeInContext`
* `LLVMX86FP80Type` -> `LLVMX86FP80TypeInContext`
* `LLVMFP128Type` -> `LLVMFP128TypeInContext`
* `LLVMPPCFP128Type` -> `LLVMPPCFP128TypeInContext`
* `LLVMStructType` -> `LLVMStructTypeInContext`
* `LLVMVoidType` -> `LLVMVoidTypeInContext`
* `LLVMLabelType` -> `LLVMLabelTypeInContext`
* `LLVMX86AMXType` -> `LLVMX86AMXTypeInContext`
* `LLVMConstString` -> `LLVMConstStringInContext2`
* `LLVMConstStruct` -> `LLVMConstStructInContext`
* `LLVMMDString` -> `LLVMMDStringInContext2`
* `LLVMMDNode` -> `LLVMMDNodeInContext2`
* `LLVMAppendBasicBlock` -> `LLVMAppendBasicBlockInContext`
* `LLVMInsertBasicBlock` -> `LLVMInsertBasicBlockInContext`
* `LLVMCreateBuilder` -> `LLVMCreateBuilderInContext`
* `LLVMIntPtrType` -> `LLVMIntPtrTypeInContext`
* `LLVMIntPtrTypeForAS` -> `LLVMIntPtrTypeForASInContext`
* `LLVMParseBitcode` -> `LLVMParseBitcodeInContext2`
* `LLVMParseBitcode2` -> `LLVMParseBitcodeInContext2`
* `LLVMGetBitcodeModule` -> `LLVMGetBitcodeModuleInContext2`
* `LLVMGetBitcodeModule2` -> `LLVMGetBitcodeModuleInContext2`

Changes to the CodeGen infrastructure
-------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ LLVMModuleRef createDemoModule(LLVMContextRef Ctx) {

// Add a "sum" function":
// - Create the function type and function instance.
LLVMTypeRef ParamTypes[] = {LLVMInt32Type(), LLVMInt32Type()};
LLVMTypeRef SumFunctionType =
LLVMFunctionType(LLVMInt32Type(), ParamTypes, 2, 0);
LLVMTypeRef Int32Type = LLVMInt32TypeInContext(Ctx);
LLVMTypeRef ParamTypes[] = {Int32Type, Int32Type};
LLVMTypeRef SumFunctionType = LLVMFunctionType(Int32Type, ParamTypes, 2, 0);
LLVMValueRef SumFunction = LLVMAddFunction(M, "sum", SumFunctionType);

// - Add a basic block to the function.
LLVMBasicBlockRef EntryBB = LLVMAppendBasicBlock(SumFunction, "entry");
LLVMBasicBlockRef EntryBB =
LLVMAppendBasicBlockInContext(Ctx, SumFunction, "entry");

// - Add an IR builder and point it at the end of the basic block.
LLVMBuilderRef Builder = LLVMCreateBuilder();
LLVMBuilderRef Builder = LLVMCreateBuilderInContext(Ctx);
LLVMPositionBuilderAtEnd(Builder, EntryBB);

// - Get the two function arguments and use them co construct an "add"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ LLVMOrcThreadSafeModuleRef createDemoModule(void) {

// Add a "sum" function":
// - Create the function type and function instance.
LLVMTypeRef ParamTypes[] = {LLVMInt32Type(), LLVMInt32Type()};
LLVMTypeRef SumFunctionType =
LLVMFunctionType(LLVMInt32Type(), ParamTypes, 2, 0);
LLVMTypeRef Int32Type = LLVMInt32TypeInContext(Ctx);
LLVMTypeRef ParamTypes[] = {Int32Type, Int32Type};
LLVMTypeRef SumFunctionType = LLVMFunctionType(Int32Type, ParamTypes, 2, 0);
LLVMValueRef SumFunction = LLVMAddFunction(M, "sum", SumFunctionType);

// - Add a basic block to the function.
LLVMBasicBlockRef EntryBB = LLVMAppendBasicBlock(SumFunction, "entry");
LLVMBasicBlockRef EntryBB =
LLVMAppendBasicBlockInContext(Ctx, SumFunction, "entry");

// - Add an IR builder and point it at the end of the basic block.
LLVMBuilderRef Builder = LLVMCreateBuilder();
LLVMBuilderRef Builder = LLVMCreateBuilderInContext(Ctx);
LLVMPositionBuilderAtEnd(Builder, EntryBB);

// - Get the two function arguments and use them co construct an "add"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ int handleError(LLVMErrorRef Err) {
LLVMOrcThreadSafeModuleRef createDemoModule(void) {
LLVMContextRef Ctx = LLVMContextCreate();
LLVMModuleRef M = LLVMModuleCreateWithNameInContext("demo", Ctx);
LLVMTypeRef ParamTypes[] = {LLVMInt32Type(), LLVMInt32Type()};
LLVMTypeRef SumFunctionType =
LLVMFunctionType(LLVMInt32Type(), ParamTypes, 2, 0);
LLVMTypeRef Int32Type = LLVMInt32TypeInContext(Ctx);
LLVMTypeRef ParamTypes[] = {Int32Type, Int32Type};
LLVMTypeRef SumFunctionType = LLVMFunctionType(Int32Type, ParamTypes, 2, 0);
LLVMValueRef SumFunction = LLVMAddFunction(M, "sum", SumFunctionType);
LLVMBasicBlockRef EntryBB = LLVMAppendBasicBlock(SumFunction, "entry");
LLVMBuilderRef Builder = LLVMCreateBuilder();
LLVMBasicBlockRef EntryBB =
LLVMAppendBasicBlockInContext(Ctx, SumFunction, "entry");
LLVMBuilderRef Builder = LLVMCreateBuilderInContext(Ctx);
LLVMPositionBuilderAtEnd(Builder, EntryBB);
LLVMValueRef SumArg0 = LLVMGetParam(SumFunction, 0);
LLVMValueRef SumArg1 = LLVMGetParam(SumFunction, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ int handleError(LLVMErrorRef Err) {
LLVMOrcThreadSafeModuleRef createDemoModule(void) {
LLVMContextRef Ctx = LLVMContextCreate();
LLVMModuleRef M = LLVMModuleCreateWithNameInContext("demo", Ctx);
LLVMTypeRef ParamTypes[] = {LLVMInt32Type(), LLVMInt32Type()};
LLVMTypeRef SumFunctionType =
LLVMFunctionType(LLVMInt32Type(), ParamTypes, 2, 0);
LLVMTypeRef Int32Type = LLVMInt32TypeInContext(Ctx);
LLVMTypeRef ParamTypes[] = {Int32Type, Int32Type};
LLVMTypeRef SumFunctionType = LLVMFunctionType(Int32Type, ParamTypes, 2, 0);
LLVMValueRef SumFunction = LLVMAddFunction(M, "sum", SumFunctionType);
LLVMBasicBlockRef EntryBB = LLVMAppendBasicBlock(SumFunction, "entry");
LLVMBuilderRef Builder = LLVMCreateBuilder();
LLVMBasicBlockRef EntryBB =
LLVMAppendBasicBlockInContext(Ctx, SumFunction, "entry");
LLVMBuilderRef Builder = LLVMCreateBuilderInContext(Ctx);
LLVMPositionBuilderAtEnd(Builder, EntryBB);
LLVMValueRef SumArg0 = LLVMGetParam(SumFunction, 0);
LLVMValueRef SumArg1 = LLVMGetParam(SumFunction, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,17 @@ LLVMOrcThreadSafeModuleRef createDemoModule(void) {

// Add a "sum" function":
// - Create the function type and function instance.
LLVMTypeRef ParamTypes[] = {LLVMInt32Type(), LLVMInt32Type()};
LLVMTypeRef SumFunctionType =
LLVMFunctionType(LLVMInt32Type(), ParamTypes, 2, 0);
LLVMTypeRef Int32Type = LLVMInt32TypeInContext(Ctx);
LLVMTypeRef ParamTypes[] = {Int32Type, Int32Type};
LLVMTypeRef SumFunctionType = LLVMFunctionType(Int32Type, ParamTypes, 2, 0);
LLVMValueRef SumFunction = LLVMAddFunction(M, "sum", SumFunctionType);

// - Add a basic block to the function.
LLVMBasicBlockRef EntryBB = LLVMAppendBasicBlock(SumFunction, "entry");
LLVMBasicBlockRef EntryBB =
LLVMAppendBasicBlockInContext(Ctx, SumFunction, "entry");

// - Add an IR builder and point it at the end of the basic block.
LLVMBuilderRef Builder = LLVMCreateBuilder();
LLVMBuilderRef Builder = LLVMCreateBuilderInContext(Ctx);
LLVMPositionBuilderAtEnd(Builder, EntryBB);

// - Get the two function arguments and use them co construct an "add"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ LLVMOrcThreadSafeModuleRef createDemoModule(void) {

// Add a "sum" function":
// - Create the function type and function instance.
LLVMTypeRef ParamTypes[] = {LLVMInt32Type(), LLVMInt32Type()};
LLVMTypeRef SumFunctionType =
LLVMFunctionType(LLVMInt32Type(), ParamTypes, 2, 0);
LLVMTypeRef Int32Type = LLVMInt32TypeInContext(Ctx);
LLVMTypeRef ParamTypes[] = {Int32Type, Int32Type};
LLVMTypeRef SumFunctionType = LLVMFunctionType(Int32Type, ParamTypes, 2, 0);
LLVMValueRef SumFunction = LLVMAddFunction(M, "sum", SumFunctionType);

// - Add a basic block to the function.
LLVMBasicBlockRef EntryBB = LLVMAppendBasicBlock(SumFunction, "entry");
LLVMBasicBlockRef EntryBB =
LLVMAppendBasicBlockInContext(Ctx, SumFunction, "entry");

// - Add an IR builder and point it at the end of the basic block.
LLVMBuilderRef Builder = LLVMCreateBuilder();
LLVMBuilderRef Builder = LLVMCreateBuilderInContext(Ctx);
LLVMPositionBuilderAtEnd(Builder, EntryBB);

// - Get the two function arguments and use them co construct an "add"
Expand Down
33 changes: 22 additions & 11 deletions llvm/include/llvm-c/BitReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef LLVM_C_BITREADER_H
#define LLVM_C_BITREADER_H

#include "llvm-c/Deprecated.h"
#include "llvm-c/ExternC.h"
#include "llvm-c/Types.h"
#include "llvm-c/Visibility.h"
Expand All @@ -37,14 +38,19 @@ LLVM_C_EXTERN_C_BEGIN
Optionally returns a human-readable error message via OutMessage.
This is deprecated. Use LLVMParseBitcode2. */
LLVM_C_ABI LLVMBool LLVMParseBitcode(LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutModule,
char **OutMessage);
LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
LLVMBool LLVMParseBitcode(LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutModule, char **OutMessage),
"Use of the global context is deprecated, use LLVMParseBitcodeInContext2 "
"instead");

/* Builds a module from the bitcode in the specified memory buffer, returning a
reference to the module via the OutModule parameter. Returns 0 on success. */
LLVM_C_ABI LLVMBool LLVMParseBitcode2(LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutModule);
LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
LLVMBool LLVMParseBitcode2(LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutModule),
"Use of the global context is deprecated, use LLVMParseBitcodeInContext2 "
"instead");

/* This is deprecated. Use LLVMParseBitcodeInContext2. */
LLVM_C_ABI LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef,
Expand Down Expand Up @@ -77,12 +83,17 @@ LLVM_C_ABI LLVMBool LLVMGetBitcodeModuleInContext2(LLVMContextRef ContextRef,
LLVMModuleRef *OutM);

/* This is deprecated. Use LLVMGetBitcodeModule2. */
LLVM_C_ABI LLVMBool LLVMGetBitcodeModule(LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutM,
char **OutMessage);

LLVM_C_ABI LLVMBool LLVMGetBitcodeModule2(LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutM);
LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
LLVMBool LLVMGetBitcodeModule(LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutM, char **OutMessage),
"Use of the global context is deprecated, use "
"LLVMGetBitcodeModuleInContext2 instead");

LLVM_C_ABI LLVM_ATTRIBUTE_C_DEPRECATED(
LLVMBool LLVMGetBitcodeModule2(LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutM),
"Use of the global context is deprecated, use "
"LLVMGetBitcodeModuleInContext2 instead");

/**
* @}
Expand Down
Loading