mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-14 09:44:26 +00:00
Move determine_asm_operand_kind upwards
This commit is contained in:
@@ -52,6 +52,35 @@ gb_internal AsmRegClass check_asm_reg_class_from_type(Type *type) {
|
||||
return AsmRegClass_Unknown;
|
||||
}
|
||||
|
||||
gb_internal AsmOperandKind determine_asm_operand_kind(Operand const *operand) {
|
||||
if (operand->mode == Addressing_Constant) {
|
||||
return AsmOperand_Immediate;
|
||||
}
|
||||
Ast *expr = operand->expr;
|
||||
switch (expr->kind) {
|
||||
case_ast_node(label, AsmLabelDecl, expr);
|
||||
return AsmOperand_Label;
|
||||
case_end;
|
||||
case_ast_node(reg, AsmRegister, expr);
|
||||
return AsmOperand_Register;
|
||||
case_end;
|
||||
case_ast_node(reg, AsmMemoryOperand, expr);
|
||||
return AsmOperand_Memory;
|
||||
case_end;
|
||||
case_ast_node(ident, Ident, expr);
|
||||
// TODO(bill): Is this correct?
|
||||
if (expr->tav.mode == Addressing_Constant) {
|
||||
return AsmOperand_Immediate;
|
||||
}
|
||||
Entity *e = entity_of_node(expr);
|
||||
if (e != nullptr && e->kind == Entity_Variable && (e->flags & EntityFlag_PolyConst) != 0) {
|
||||
return AsmOperand_Immediate;
|
||||
}
|
||||
return AsmOperand_Register;
|
||||
case_end;
|
||||
}
|
||||
return AsmOperand_Invalid;
|
||||
}
|
||||
|
||||
enum AsmMismatch : u8 {
|
||||
AsmMismatch_None,
|
||||
@@ -702,36 +731,6 @@ gb_internal CheckMnemomicResult check_mnemonic_name(AsmCtx *asm_ctx, AstAsmInstr
|
||||
return CheckMnemomic_Invalid;
|
||||
}
|
||||
|
||||
gb_internal AsmOperandKind determine_asm_operand_kind(Operand const *operand) {
|
||||
if (operand->mode == Addressing_Constant) {
|
||||
return AsmOperand_Immediate;
|
||||
}
|
||||
Ast *expr = operand->expr;
|
||||
switch (expr->kind) {
|
||||
case_ast_node(label, AsmLabelDecl, expr);
|
||||
return AsmOperand_Label;
|
||||
case_end;
|
||||
case_ast_node(reg, AsmRegister, expr);
|
||||
return AsmOperand_Register;
|
||||
case_end;
|
||||
case_ast_node(reg, AsmMemoryOperand, expr);
|
||||
return AsmOperand_Memory;
|
||||
case_end;
|
||||
case_ast_node(ident, Ident, expr);
|
||||
// TODO(bill): Is this correct?
|
||||
if (expr->tav.mode == Addressing_Constant) {
|
||||
return AsmOperand_Immediate;
|
||||
}
|
||||
Entity *e = entity_of_node(expr);
|
||||
if (e != nullptr && e->kind == Entity_Variable && (e->flags & EntityFlag_PolyConst) != 0) {
|
||||
return AsmOperand_Immediate;
|
||||
}
|
||||
return AsmOperand_Register;
|
||||
case_end;
|
||||
}
|
||||
return AsmOperand_Invalid;
|
||||
}
|
||||
|
||||
|
||||
template <typename AsmCtx>
|
||||
gb_internal void check_mnemonic(AsmCtx *asm_ctx, CheckerContext *ctx, Entity *tmpl_entity, AstAsmInstruction *instr,
|
||||
|
||||
Reference in New Issue
Block a user