c3ba03a5a18d0d98ad70c8f84f17fba95fc2f403
1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
32 * @author Jose Fonseca <jfonseca@vmware.com>
36 #include <llvm-c/Transforms/Scalar.h>
38 #include "lp_screen.h"
43 lp_jit_screen_cleanup(struct llvmpipe_screen
*screen
)
46 LLVMDisposeExecutionEngine(screen
->engine
);
49 LLVMDisposePassManager(screen
->pass
);
54 lp_jit_screen_init(struct llvmpipe_screen
*screen
)
58 screen
->module
= LLVMModuleCreateWithName("llvmpipe");
60 screen
->provider
= LLVMCreateModuleProviderForExistingModule(screen
->module
);
62 if (LLVMCreateJITCompiler(&screen
->engine
, screen
->provider
, 1, &error
)) {
63 fprintf(stderr
, "%s\n", error
);
64 LLVMDisposeMessage(error
);
68 screen
->pass
= LLVMCreateFunctionPassManager(screen
->provider
);
69 LLVMAddTargetData(LLVMGetExecutionEngineTargetData(screen
->engine
), screen
->pass
);
70 /* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
71 * but there are more on SVN. */
72 LLVMAddConstantPropagationPass(screen
->pass
);
73 LLVMAddInstructionCombiningPass(screen
->pass
);
74 LLVMAddPromoteMemoryToRegisterPass(screen
->pass
);
75 LLVMAddGVNPass(screen
->pass
);
76 LLVMAddCFGSimplificationPass(screen
->pass
);