forked from klee/klee
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d0033f
commit 99c522b
Showing
11 changed files
with
176 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//===-- KCallable.h ---------------------------------------------*- C++ -*-===// | ||
// | ||
// The KLEE Symbolic Virtual Machine | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef KLEE_KCALLABLE_H | ||
#define KLEE_KCALLABLE_H | ||
|
||
#include <string> | ||
|
||
#include "llvm/ADT/Twine.h" | ||
#include "llvm/IR/Function.h" | ||
#include "llvm/IR/InlineAsm.h" | ||
#include "llvm/IR/LLVMContext.h" | ||
|
||
namespace klee { | ||
/// Wrapper for callable objects passed in callExternalFunction | ||
class KCallable { | ||
public: | ||
enum CallableKind { CK_Function, CK_InlineAsm }; | ||
|
||
private: | ||
const CallableKind Kind; | ||
|
||
public: | ||
KCallable(CallableKind Kind) : Kind(Kind) {} | ||
|
||
CallableKind getKind() const { return Kind; } | ||
|
||
virtual llvm::StringRef getName() const = 0; | ||
virtual llvm::PointerType *getType() const = 0; | ||
virtual llvm::Value *getValue() = 0; | ||
|
||
virtual ~KCallable() = default; | ||
}; | ||
|
||
class KInlineAsm : public KCallable { | ||
private: | ||
static unsigned getFreshAsmId() { | ||
static unsigned globalId = 0; | ||
return globalId++; | ||
} | ||
|
||
llvm::InlineAsm *value; | ||
std::string name; | ||
|
||
public: | ||
KInlineAsm(llvm::InlineAsm *value) | ||
: KCallable(CK_InlineAsm), value(value), | ||
name("__asm__" + llvm::Twine(getFreshAsmId()).str()) {} | ||
|
||
llvm::StringRef getName() const override { return name; } | ||
|
||
llvm::PointerType *getType() const override { return value->getType(); } | ||
|
||
llvm::Value *getValue() override { return value; } | ||
|
||
static bool classof(const KCallable *callable) { | ||
return callable->getKind() == CK_InlineAsm; | ||
} | ||
|
||
llvm::InlineAsm *getInlineAsm() { return value; } | ||
}; | ||
|
||
} // namespace klee | ||
|
||
#endif /* KLEE_KCALLABLE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.