Skip to content
Snippets Groups Projects
Commit 4d0589d9 authored by Andrea Shepard's avatar Andrea Shepard
Browse files

Implement LLVM backend for h_nothing_p()

parent 68dafe8d
No related branches found
No related tags found
No related merge requests found
#ifdef HAMMER_LLVM_BACKEND
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#include <llvm-c/Core.h>
#pragma GCC diagnostic pop
#include "../backends/llvm/llvm.h"
#endif
#include "parser_internal.h"
static HParseResult* parse_nothing() {
......@@ -16,12 +23,32 @@ static bool nothing_ctrvm(HRVMProg *prog, void* env) {
return true;
}
#ifdef HAMMER_LLVM_BACKEND
static bool nothing_llvm(HLLVMParserCompileContext *ctxt, void* env) {
if (!ctxt) return false;
/* This one just always returns NULL */
LLVMBasicBlockRef entry = LLVMAppendBasicBlock(ctxt->func, "nothing_entry");
LLVMBuildBr(ctxt->builder, entry);
LLVMPositionBuilderAtEnd(ctxt->builder, entry);
LLVMBuildRet(ctxt->builder, LLVMConstNull(ctxt->llvm_parseresultptr));
return true;
}
#endif /* defined(HAMMER_LLVM_BACKEND) */
static const HParserVtable nothing_vt = {
.parse = parse_nothing,
.isValidRegular = h_true,
.isValidCF = h_true,
.desugar = desugar_nothing,
.compile_to_rvm = nothing_ctrvm,
#ifdef HAMMER_LLVM_BACKEND
.llvm = nothing_llvm,
#endif
.higher = false,
};
......
......@@ -1049,5 +1049,6 @@ void register_parser_tests(void) {
g_test_add_data_func("/core/parser/llvm/uint8", GINT_TO_POINTER(PB_LLVM), test_uint8);
g_test_add_data_func("/core/parser/llvm/in", GINT_TO_POINTER(PB_LLVM), test_in);
g_test_add_data_func("/core/parser/llvm/not_in", GINT_TO_POINTER(PB_LLVM), test_not_in);
g_test_add_data_func("/core/parser/llvm/nothing_p", GINT_TO_POINTER(PB_LLVM), test_nothing_p);
#endif /* defined(HAMMER_LLVM_BACKEND) */
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment