#include "TableGen.h"
#include "TableGen.hpp"
#include "Types.h"
using namespace llvm;
TableGenStringRef tableGenRecordValGetName(TableGenRecordValRef rv_ref) {
auto s = unwrap(rv_ref)->getName();
return TableGenStringRef{.data = s.data(), .len = s.size()};
}
TableGenTypedInitRef tableGenRecordValGetNameInit(TableGenRecordValRef rv_ref) {
return wrap(dyn_cast<TypedInit>(unwrap(rv_ref)->getNameInit()));
}
TableGenRecTyKind tableGenRecordValGetType(TableGenRecordValRef rv_ref) {
return ctablegen::tableGenFromRecType(unwrap(rv_ref)->getType());
}
TableGenTypedInitRef tableGenRecordValGetValue(TableGenRecordValRef rv_ref) {
return wrap(dyn_cast<TypedInit>(unwrap(rv_ref)->getValue()));
}
char *tableGenRecordValGetValAsNewString(TableGenRecordValRef rv_ref) {
return tableGenStringInitGetValueNewString(
wrap(dyn_cast<TypedInit>(unwrap(rv_ref)->getValue())));
}
TableGenBool tableGenRecordValGetValAsBit(TableGenRecordValRef rv_ref,
int8_t *bit) {
return tableGenBitInitGetValue(
wrap(dyn_cast<TypedInit>(unwrap(rv_ref)->getValue())), bit);
}
TableGenBool tableGenRecordValGetValAsInt(TableGenRecordValRef rv_ref,
int64_t *integer) {
return tableGenIntInitGetValue(
wrap(dyn_cast<TypedInit>(unwrap(rv_ref)->getValue())), integer);
}
TableGenRecordRef
tableGenRecordValGetValAsDefRecord(TableGenRecordValRef rv_ref) {
return tableGenDefInitGetValue(
wrap(dyn_cast<TypedInit>(unwrap(rv_ref)->getValue())));
}
void tableGenRecordValPrint(TableGenRecordValRef rv_ref,
TableGenStringCallback callback, void *userData) {
ctablegen::CallbackOstream stream(callback, userData);
stream << *unwrap(rv_ref);
}
void tableGenRecordValDump(TableGenRecordValRef rv_ref) {
errs() << *unwrap(rv_ref);
}
TableGenSourceLocationRef tableGenRecordValGetLoc(TableGenRecordValRef rv_ref) {
auto loc = unwrap(rv_ref)->getLoc();
return wrap(new std::vector<SMLoc>(1, loc));
}
size_t tableGenRecordValGetBitsWidth(TableGenRecordValRef rv_ref) {
auto *bits_ty = dyn_cast<BitsRecTy>(unwrap(rv_ref)->getType());
if (!bits_ty)
return 0;
return bits_ty->getNumBits();
}
TableGenRecTyKind
tableGenRecordValGetListElementType(TableGenRecordValRef rv_ref) {
auto *list_ty = dyn_cast<ListRecTy>(unwrap(rv_ref)->getType());
if (!list_ty)
return TableGenInvalidRecTyKind;
return ctablegen::tableGenFromRecType(list_ty->getElementType());
}
TableGenBool tableGenRecordValIsTemplateArg(TableGenRecordValRef rv_ref) {
return unwrap(rv_ref)->isTemplateArg();
}
TableGenBool tableGenRecordValIsNonconcreteOK(TableGenRecordValRef rv_ref) {
return unwrap(rv_ref)->isNonconcreteOK();
}