| OLD | NEW |
| 1 //===- MCJITTest.cpp - Unit tests for the MCJIT ---------------------------===// | 1 //===- MCJITTest.cpp - Unit tests for the MCJIT ---------------------------===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This test suite verifies basic MCJIT functionality when invoked form the C | 10 // This test suite verifies basic MCJIT functionality when invoked form the C |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 TEST_F(MCJITCAPITest, simple_function) { | 43 TEST_F(MCJITCAPITest, simple_function) { |
| 44 SKIP_UNSUPPORTED_PLATFORM; | 44 SKIP_UNSUPPORTED_PLATFORM; |
| 45 | 45 |
| 46 char *error = 0; | 46 char *error = 0; |
| 47 | 47 |
| 48 // Creates a function that returns 42, compiles it, and runs it. | 48 // Creates a function that returns 42, compiles it, and runs it. |
| 49 | 49 |
| 50 LLVMModuleRef module = LLVMModuleCreateWithName("simple_module"); | 50 LLVMModuleRef module = LLVMModuleCreateWithName("simple_module"); |
| 51 | |
| 52 LLVMSetTarget(module, HostTriple.c_str()); | |
| 53 | 51 |
| 54 LLVMValueRef function = LLVMAddFunction( | 52 LLVMValueRef function = LLVMAddFunction( |
| 55 module, "simple_function", LLVMFunctionType(LLVMInt32Type(), 0, 0, 0)); | 53 module, "simple_function", LLVMFunctionType(LLVMInt32Type(), 0, 0, 0)); |
| 56 LLVMSetFunctionCallConv(function, LLVMCCallConv); | 54 LLVMSetFunctionCallConv(function, LLVMCCallConv); |
| 57 | 55 |
| 58 LLVMBasicBlockRef entry = LLVMAppendBasicBlock(function, "entry"); | 56 LLVMBasicBlockRef entry = LLVMAppendBasicBlock(function, "entry"); |
| 59 LLVMBuilderRef builder = LLVMCreateBuilder(); | 57 LLVMBuilderRef builder = LLVMCreateBuilder(); |
| 60 LLVMPositionBuilderAtEnd(builder, entry); | 58 LLVMPositionBuilderAtEnd(builder, entry); |
| 61 LLVMBuildRet(builder, LLVMConstInt(LLVMInt32Type(), 42, 0)); | 59 LLVMBuildRet(builder, LLVMConstInt(LLVMInt32Type(), 42, 0)); |
| 62 | 60 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 88 void *raw; | 86 void *raw; |
| 89 int (*usable)(); | 87 int (*usable)(); |
| 90 } functionPointer; | 88 } functionPointer; |
| 91 functionPointer.raw = LLVMGetPointerToGlobal(engine, function); | 89 functionPointer.raw = LLVMGetPointerToGlobal(engine, function); |
| 92 | 90 |
| 93 EXPECT_EQ(42, functionPointer.usable()); | 91 EXPECT_EQ(42, functionPointer.usable()); |
| 94 | 92 |
| 95 LLVMDisposeExecutionEngine(engine); | 93 LLVMDisposeExecutionEngine(engine); |
| 96 } | 94 } |
| 97 | 95 |
| OLD | NEW |