-
Notifications
You must be signed in to change notification settings - Fork 59
/
binary_result.h
68 lines (47 loc) · 2.29 KB
/
binary_result.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*****************************************************************************\
Copyright (c) Intel Corporation (2009-2017).
INTEL MAKES NO WARRANTY OF ANY KIND REGARDING THE CODE. THIS CODE IS
LICENSED ON AN "AS IS" BASIS AND INTEL WILL NOT PROVIDE ANY SUPPORT,
ASSISTANCE, INSTALLATION, TRAINING OR OTHER SERVICES. INTEL DOES NOT
PROVIDE ANY UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY
DISCLAIMS ANY WARRANTY OF MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR ANY
PARTICULAR PURPOSE, OR ANY OTHER WARRANTY. Intel disclaims all liability,
including liability for infringement of any proprietary rights, relating to
use of the code. No license, express or implied, by estoppel or otherwise,
to any intellectual property rights is granted herein.
\file binary_result.h
\*****************************************************************************/
#pragma once
#include "opencl_clang.h"
#include "llvm/ADT/SmallVector.h"
#include <string>
// The following #define is taken from
// https://github.com/KhronosGroup/OpenCL-Headers/blob/master/CL/cl.h
#define CL_SUCCESS 0
class OCLFEBinaryResult : public Intel::OpenCL::ClangFE::IOCLFEBinaryResult {
// IOCLFEBinaryResult
public:
size_t GetIRSize() const override { return m_IRBuffer.size(); }
const void *GetIR() const override { return m_IRBuffer.data(); }
const char *GetIRName() const override { return m_IRName.c_str(); }
Intel::OpenCL::ClangFE::IR_TYPE GetIRType() const override { return m_type; }
const char *GetErrorLog() const override { return m_log.c_str(); }
void Release() override { delete this; }
// OCLFEBinaryResult
public:
OCLFEBinaryResult()
: m_type(Intel::OpenCL::ClangFE::IR_TYPE_UNKNOWN), m_result(CL_SUCCESS) {}
llvm::SmallVectorImpl<char> &getIRBufferRef() { return m_IRBuffer; }
std::string &getLogRef() { return m_log; }
void setLog(const std::string &log) { m_log = log; }
void setIRName(const std::string &name) { m_IRName = name; }
void setIRType(Intel::OpenCL::ClangFE::IR_TYPE type) { m_type = type; }
void setResult(int result) { m_result = result; }
int getResult(void) const { return m_result; }
private:
llvm::SmallVector<char, 4096> m_IRBuffer;
std::string m_log;
std::string m_IRName;
Intel::OpenCL::ClangFE::IR_TYPE m_type;
int m_result;
};