Files
triton/examples/matrix.cpp

44 lines
1.2 KiB
C++
Raw Normal View History

2018-12-15 22:29:36 -05:00
#include <cstring>
#include <cstdio>
#include "ast/ast.h"
2019-01-03 17:14:54 -05:00
#include "ir/context.h"
#include "ir/module.h"
#include "codegen/selection.h"
2019-01-05 19:23:00 -05:00
#include "llvm/IR/IRPrintingPasses.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/LLVMContext.h"
2019-01-06 00:53:11 -05:00
#include "llvm/IR/PassManager.h"
#include "llvm/Support/raw_ostream.h"
2018-12-15 22:29:36 -05:00
typedef struct yy_buffer_state * YY_BUFFER_STATE;
extern int yyparse();
extern YY_BUFFER_STATE yy_scan_string(const char * str);
extern void yy_delete_buffer(YY_BUFFER_STATE buffer);
2018-12-17 10:43:49 -05:00
using tdl::ast::translation_unit;
2018-12-16 16:15:40 -05:00
extern translation_unit *ast_root;
2018-12-15 22:29:36 -05:00
const char src[] =
"\
void test(fp32 *A, fp32 *B, fp32 *C, int32 i){\
i = 1;\
A = A + i;\
}\
";
2018-12-15 22:29:36 -05:00
int main() {
YY_BUFFER_STATE buffer = yy_scan_string(src);
yyparse();
2018-12-15 22:29:36 -05:00
yy_delete_buffer(buffer);
2019-01-03 17:14:54 -05:00
translation_unit *program = ast_root;
tdl::ir::context context;
tdl::ir::module module("matrix", context);
program->codegen(&module);
2019-01-05 19:23:00 -05:00
llvm::LLVMContext llvm_context;
llvm::Module llvm_module("test", llvm_context);
tdl::codegen::lowering(module, llvm_module);
2019-01-06 00:53:11 -05:00
llvm::PrintModulePass print(llvm::outs());
llvm::AnalysisManager<llvm::Module> analysis;
print.run(llvm_module, analysis);
2018-12-15 22:29:36 -05:00
return 0;
}