Files
revng-revng/lib/DataLayoutAnalysis/FuncOrCallInst.cpp
T
Giacomo Vercesi ab125b35b0 Fix License headers
Change company name to "rev.ng Labs Srl" in all license headers
to reflect changed company name and legal status
Add missing license headers to files that didn't have one
2022-04-19 12:17:59 +02:00

49 lines
1.7 KiB
C++

//
// Copyright (c) rev.ng Labs Srl. See LICENSE.md for details.
//
#include "FuncOrCallInst.h"
using namespace dla;
using namespace llvm;
bool FuncOrCallInst::isNull() const {
if (holds_alternative<const Function *>(Val))
return get<const Function *>(Val) == nullptr;
if (holds_alternative<const CallInst *>(Val))
return get<const CallInst *>(Val) == nullptr;
revng_abort("Can only be Function or CallInst");
}
const Value *FuncOrCallInst::getVal() const {
if (holds_alternative<const Function *>(Val))
return static_cast<const Value *>(get<const Function *>(Val));
if (holds_alternative<const CallInst *>(Val))
return static_cast<const Value *>(get<const CallInst *>(Val));
revng_abort("Can only be Function or CallInst");
}
const Type *FuncOrCallInst::getRetType() const {
if (holds_alternative<const Function *>(Val))
return dla::getRetType(get<const Function *>(Val));
if (holds_alternative<const CallInst *>(Val))
return dla::getRetType(get<const CallInst *>(Val));
revng_abort("Can only be Function or CallInst");
}
unsigned long FuncOrCallInst::arg_size() const {
if (holds_alternative<const Function *>(Val))
return dla::arg_size(get<const Function *>(Val));
if (holds_alternative<const CallInst *>(Val))
return dla::arg_size(get<const CallInst *>(Val));
revng_abort("Can only be Function or CallInst");
}
const Value *FuncOrCallInst::getArg(unsigned Idx) const {
if (holds_alternative<const Function *>(Val))
return dla::getArgs(get<const Function *>(Val)).begin() + Idx;
if (holds_alternative<const CallInst *>(Val))
return *(dla::getArgs(get<const CallInst *>(Val)).begin() + Idx);
revng_abort("Can only be Function or CallInst");
}