forked from google/swiftshader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LLVMAsm.hpp
45 lines (35 loc) · 1.65 KB
/
LLVMAsm.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2020 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef rr_LLVMAsm_hpp
#define rr_LLVMAsm_hpp
#ifdef ENABLE_RR_EMIT_ASM_FILE
# include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
# include <string>
# include <vector>
namespace rr {
namespace AsmFile {
// Generate a unique name for the asm file
std::string generateFilename(std::string routineName);
// Emit an asm file for the current module
bool emitAsmFile(const std::string &filename, llvm::orc::JITTargetMachineBuilder builder, llvm::Module &module);
// Rewrites the previously generated asm file, adding extra useful information.
// In particular, it prepends the final resolved location (address) of each instruction.
// NOTE: Doing this is error-prone since we parse text, and are thus dependent on the
// exact format of LLVM's assembly output. It would be nice if LLVM's asm output included
// at least the 0-based relative address of each instruction.
void fixupAsmFile(const std::string &filename, std::vector<const void *> addresses);
} // namespace AsmFile
} // namespace rr
#endif // ENABLE_RR_EMIT_ASM_FILE
#endif // rr_LLVMAsm_hpp