Fix asm string bug.

This commit is contained in:
Christoffer Lerno
2022-09-13 19:15:17 +02:00
parent 3a09f71830
commit 03c627f646
6 changed files with 9 additions and 9 deletions

View File

@@ -1328,7 +1328,7 @@ typedef struct
bool is_volatile : 1;
bool is_inline : 1;
bool is_goto : 1;
bool string : 1;
bool is_string : 1;
union
{
AsmInlineBlock *block;

View File

@@ -417,7 +417,7 @@ RETRY:
doc_ast_copy(c, &source->doc_stmt);
break;
case AST_ASM_BLOCK_STMT:
if (ast->asm_block_stmt.string)
if (ast->asm_block_stmt.is_string)
{
MACRO_COPY_EXPRID(ast->asm_block_stmt.asm_string);
}

View File

@@ -1060,7 +1060,7 @@ static inline void llvm_emit_asm_block_stmt(GenContext *c, Ast *ast)
unsigned result_count = 0;
unsigned param_count = 0;
AsmInlineBlock *block = ast->asm_block_stmt.block;
if (ast->asm_block_stmt.string)
if (ast->asm_block_stmt.is_string)
{
data = exprptr(ast->asm_block_stmt.asm_string)->const_expr.string.chars;
}
@@ -1187,7 +1187,7 @@ static inline void llvm_emit_asm_block_stmt(GenContext *c, Ast *ast)
strlen(clobbers),
ast->asm_block_stmt.is_volatile,
true,
ast->asm_block_stmt.string ? LLVMInlineAsmDialectIntel : LLVMInlineAsmDialectATT
ast->asm_block_stmt.is_string ? LLVMInlineAsmDialectIntel : LLVMInlineAsmDialectATT
#if LLVM_VERSION_MAJOR > 12
, /* can throw */ false
#endif

View File

@@ -308,10 +308,10 @@ static inline Ast* parse_asm_block_stmt(ParseContext *c)
ast->asm_block_stmt.block = block;
return ast;
}
ast->asm_block_stmt.string = true;
ast->asm_block_stmt.is_string = true;
// TODO use attributes, like volatile
CONSUME_OR_RET(TOKEN_LPAREN, poisoned_ast);
ASSIGN_EXPRID_OR_RET(ast->asm_block_stmt.string, parse_expr(c), poisoned_ast);
ASSIGN_EXPRID_OR_RET(ast->asm_block_stmt.asm_string, parse_expr(c), poisoned_ast);
ast->asm_block_stmt.is_volatile = true;
CONSUME_OR_RET(TOKEN_RPAREN, poisoned_ast);
RANGE_EXTEND_PREV(ast);

View File

@@ -1348,7 +1348,7 @@ static inline bool sema_analyse_if_stmt(SemaContext *context, Ast *statement)
static bool sema_analyse_asm_string_stmt(SemaContext *context, Ast *stmt)
{
Expr *body = exprptr(stmt->asm_block_stmt.string);
Expr *body = exprptr(stmt->asm_block_stmt.asm_string);
if (!sema_analyse_expr(context, body)) return false;
if (!expr_is_const_string(body))
{
@@ -1360,7 +1360,7 @@ static bool sema_analyse_asm_string_stmt(SemaContext *context, Ast *stmt)
static bool sema_analyse_asm_stmt(SemaContext *context, Ast *stmt)
{
if (stmt->asm_block_stmt.string) return sema_analyse_asm_string_stmt(context, stmt);
if (stmt->asm_block_stmt.is_string) return sema_analyse_asm_string_stmt(context, stmt);
AsmInlineBlock *block = stmt->asm_block_stmt.block;
AstId ast_id = block->asm_stmt;
scratch_buffer_clear();

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.3.39"
#define COMPILER_VERSION "0.3.40"