-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathGetMemOper.cpp
More file actions
45 lines (31 loc) · 1000 Bytes
/
GetMemOper.cpp
File metadata and controls
45 lines (31 loc) · 1000 Bytes
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
#include "scaf/Utilities/GetMemOper.h"
using namespace llvm;
const Value *liberty::getMemOper(const Instruction *inst) {
return getMemOper(const_cast<Instruction *>(inst));
}
Value *liberty::getMemOper(Instruction *inst) {
if (LoadInst *load = dyn_cast<LoadInst>(inst))
return load->getPointerOperand();
if (StoreInst *store = dyn_cast<StoreInst>(inst))
return store->getPointerOperand();
if (MemSetInst *msi = dyn_cast<MemSetInst>(inst))
return msi->getRawDest();
if (isa<MemIntrinsic>(inst))
return NULL;
if (isa<VAArgInst>(inst))
assert(false && "Variadic arguments not supported");
return NULL;
}
void liberty::setMemOper(Instruction *inst, Value *value) {
if (isa<LoadInst>(inst)) {
inst->setOperand(0, value);
return;
}
if (isa<StoreInst>(inst)) {
inst->setOperand(1, value);
return;
}
if (isa<MemIntrinsic>(inst) || isa<VAArgInst>(inst))
assert(false && "Unimplemented");
assert(false && "No memory operator");
}