mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
add ability for TinyCC to compile c3c (#2459)
* add ability for TinyCC to compile c3c --------- Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
@@ -678,7 +678,7 @@ static inline void llvm_emit_subscript_addr_with_base(GenContext *c, BEValue *re
|
||||
}
|
||||
return;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
|
||||
}
|
||||
}
|
||||
@@ -867,7 +867,7 @@ static void llvm_emit_member_addr(GenContext *c, BEValue *value, Decl *parent, D
|
||||
llvm_value_struct_gep(c, value, value, (unsigned)index);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
parent = found;
|
||||
} while (found != member);
|
||||
@@ -1508,7 +1508,7 @@ static void llvm_emit_const_init_ref(GenContext *c, BEValue *ref, ConstInitializ
|
||||
llvm_store_zero(c, ref);
|
||||
return;
|
||||
case CONST_INIT_ARRAY_VALUE:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case CONST_INIT_ARRAY_FULL:
|
||||
{
|
||||
LLVMValueRef array_ref = ref->value;
|
||||
@@ -1580,7 +1580,7 @@ static void llvm_emit_const_init_ref(GenContext *c, BEValue *ref, ConstInitializ
|
||||
return;
|
||||
}
|
||||
}
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
|
||||
static inline void llvm_emit_initialize_reference_vector(GenContext *c, BEValue *ref, Type *real_type, Expr **elements)
|
||||
@@ -1817,7 +1817,7 @@ static void llvm_emit_initialize_designated_element(GenContext *c, BEValue *ref,
|
||||
llvm_emit_initialize_designated_const_range(c, ref, offset, current, last, expr, emitted_value);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2070,7 +2070,7 @@ static inline void llvm_emit_initialize_reference(GenContext *c, BEValue *ref, E
|
||||
llvm_emit_initialize_reference_designated(c, ref, expr);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2187,7 +2187,7 @@ static void llvm_emit_vec_comp(GenContext *c, BEValue *result, BEValue *lhs, BEV
|
||||
res = LLVMBuildFCmp(c->builder, LLVMRealOLT, lhs->value, rhs->value, "lt");
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2216,7 +2216,7 @@ static void llvm_emit_vec_comp(GenContext *c, BEValue *result, BEValue *lhs, BEV
|
||||
res = LLVMBuildICmp(c->builder, is_signed ? LLVMIntSLT : LLVMIntULT, lhs->value, rhs->value, "lt");
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
}
|
||||
llvm_value_set(result, res, type);
|
||||
@@ -2462,7 +2462,7 @@ static void llvm_emit_unary_expr(GenContext *c, BEValue *value, Expr *expr)
|
||||
FATAL_ERROR("Illegal unary op %s", expr->unary_expr.operator);
|
||||
case UNARYOP_PLUS:
|
||||
// Folded
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case UNARYOP_NOT:
|
||||
llvm_emit_expr(c, value, inner);
|
||||
if (type_flat_is_vector(type))
|
||||
@@ -2550,7 +2550,7 @@ static void llvm_emit_unary_expr(GenContext *c, BEValue *value, Expr *expr)
|
||||
llvm_emit_pre_inc_dec(c, value, inner, -1, !expr->unary_expr.no_wrap);
|
||||
return;
|
||||
}
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
|
||||
|
||||
@@ -2677,7 +2677,7 @@ static void llvm_emit_slice_values(GenContext *c, Expr *slice, BEValue *parent_r
|
||||
parent_base = parent_addr;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
|
||||
// Emit the start and end
|
||||
@@ -2688,7 +2688,7 @@ static void llvm_emit_slice_values(GenContext *c, Expr *slice, BEValue *parent_r
|
||||
switch (range.range_type)
|
||||
{
|
||||
case RANGE_SINGLE_ELEMENT:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case RANGE_DYNAMIC:
|
||||
case RANGE_CONST_LEN:
|
||||
case RANGE_CONST_END:
|
||||
@@ -2725,7 +2725,7 @@ static void llvm_emit_slice_values(GenContext *c, Expr *slice, BEValue *parent_r
|
||||
llvm_value_set_int(c, &len, start_type, parent_type->array.len);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2759,7 +2759,7 @@ static void llvm_emit_slice_values(GenContext *c, Expr *slice, BEValue *parent_r
|
||||
switch (range.range_type)
|
||||
{
|
||||
case RANGE_SINGLE_ELEMENT:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case RANGE_DYNAMIC:
|
||||
llvm_emit_exprid(c, &end_index, range.end);
|
||||
llvm_value_rvalue(c, &end_index);
|
||||
@@ -2877,7 +2877,7 @@ static void gencontext_emit_slice(GenContext *c, BEValue *be_value, Expr *expr)
|
||||
start_pointer = llvm_emit_pointer_inbounds_gep_raw(c, llvm_get_pointee_type(c, parent.type), parent.value, start.value);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
|
||||
// Create a new slice type
|
||||
@@ -3178,7 +3178,7 @@ void llvm_emit_int_comp_raw(GenContext *c, BEValue *result, Type *lhs_type, Type
|
||||
llvm_value_set(result, llvm_const_int(c, type_bool, 1), type_bool);
|
||||
return;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
}
|
||||
lhs_signed = false;
|
||||
@@ -3210,7 +3210,7 @@ void llvm_emit_int_comp_raw(GenContext *c, BEValue *result, Type *lhs_type, Type
|
||||
value = LLVMBuildICmp(c->builder, LLVMIntULT, lhs_value, rhs_value, "lt");
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
if (vector_type)
|
||||
{
|
||||
@@ -3247,7 +3247,7 @@ void llvm_emit_int_comp_raw(GenContext *c, BEValue *result, Type *lhs_type, Type
|
||||
comp_value = LLVMBuildICmp(c->builder, LLVMIntSLT, lhs_value, rhs_value, "lt");
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
|
||||
// If right side is also signed then this is fine.
|
||||
@@ -3297,7 +3297,7 @@ void llvm_emit_int_comp_raw(GenContext *c, BEValue *result, Type *lhs_type, Type
|
||||
comp_value = LLVMBuildOr(c->builder, check_value, comp_value, "siui-lt");
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
if (vector_type)
|
||||
{
|
||||
@@ -3335,7 +3335,7 @@ static void llvm_emit_ptr_comparison(GenContext *c, BEValue *result, BEValue *lh
|
||||
val = LLVMBuildICmp(c->builder, LLVMIntULT, lhs_value, rhs_value, "lt");
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
llvm_value_set(result, val, type_bool);
|
||||
}
|
||||
@@ -3369,7 +3369,7 @@ static void llvm_emit_any_comparison(GenContext *c, BEValue *result, BEValue *lh
|
||||
res = LLVMBuildOr(c->builder, val, val2, "any_ne");
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
llvm_value_set(result, res, type_bool);
|
||||
}
|
||||
@@ -3604,7 +3604,7 @@ MEMCMP:
|
||||
case TYPE_WILDCARD:
|
||||
case TYPE_TYPEINFO:
|
||||
case TYPE_MEMBER:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case TYPE_BOOL:
|
||||
case ALL_FLOATS:
|
||||
case TYPE_SLICE:
|
||||
@@ -3737,7 +3737,7 @@ static void llvm_emit_float_comp(GenContext *c, BEValue *be_value, BEValue *lhs,
|
||||
val = LLVMBuildFCmp(c->builder, LLVMRealOLT, lhs_value, rhs_value, "lt");
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
if (vector_type)
|
||||
{
|
||||
@@ -3783,7 +3783,7 @@ void llvm_emit_comp(GenContext *c, BEValue *result, BEValue *lhs, BEValue *rhs,
|
||||
switch (lhs->type->type_kind)
|
||||
{
|
||||
case TYPE_VOID:
|
||||
UNREACHABLE;
|
||||
UNREACHABLE_VOID;
|
||||
case TYPE_BOOL:
|
||||
case ALL_INTS:
|
||||
llvm_value_rvalue(c, lhs);
|
||||
@@ -3807,7 +3807,7 @@ void llvm_emit_comp(GenContext *c, BEValue *result, BEValue *lhs, BEValue *rhs,
|
||||
return;
|
||||
case LOWERED_TYPES:
|
||||
case TYPE_FLEXIBLE_ARRAY:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case TYPE_STRUCT:
|
||||
case TYPE_UNION:
|
||||
llvm_emit_struct_comparison(c, result, lhs, rhs, binary_op);
|
||||
@@ -4039,7 +4039,7 @@ void llvm_emit_bitstruct_binary_op(GenContext *c, BEValue *be_value, BEValue *lh
|
||||
val = LLVMBuildXor(c->builder, l, r, "xor");
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
LLVMValueRef store = llvm_emit_alloca(c, big_int, lhs->alignment, "");
|
||||
llvm_store_to_ptr_raw_aligned(c, store, val, lhs->alignment);
|
||||
@@ -4119,7 +4119,7 @@ void llvm_emit_binary(GenContext *c, BEValue *be_value, Expr *expr, BEValue *lhs
|
||||
switch (binary_op)
|
||||
{
|
||||
case BINARYOP_ERROR:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case BINARYOP_MULT:
|
||||
if (is_float)
|
||||
{
|
||||
@@ -4277,7 +4277,7 @@ void llvm_emit_binary(GenContext *c, BEValue *be_value, Expr *expr, BEValue *lhs
|
||||
case BINARYOP_CT_OR:
|
||||
case BINARYOP_CT_CONCAT:
|
||||
// Handled elsewhere.
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
ASSERT(val);
|
||||
llvm_value_set(be_value, val, expr->type);
|
||||
@@ -4881,7 +4881,7 @@ static void llvm_emit_const_expr(GenContext *c, BEValue *be_value, Expr *expr)
|
||||
llvm_value_set(be_value, NULL, type_void);
|
||||
return;
|
||||
}
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
|
||||
|
||||
@@ -4922,7 +4922,7 @@ static void llvm_expand_type_to_args(GenContext *context, Type *param_type, LLVM
|
||||
case TYPE_VOID:
|
||||
case TYPE_FUNC_RAW:
|
||||
case TYPE_FLEXIBLE_ARRAY:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
break;
|
||||
case TYPE_BOOL:
|
||||
case ALL_INTS:
|
||||
@@ -5371,7 +5371,7 @@ void llvm_emit_raw_call(GenContext *c, BEValue *result_value, FunctionPrototype
|
||||
{
|
||||
case ABI_ARG_EXPAND:
|
||||
case ABI_ARG_DIRECT_SPLIT_STRUCT_I32:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case ABI_ARG_IGNORE:
|
||||
// 12. Basically void returns or empty structs.
|
||||
// Here we know we don't have an optional or any return value that can be used.
|
||||
@@ -5744,7 +5744,7 @@ INLINE void llvm_emit_call_invocation(GenContext *c, BEValue *result_value,
|
||||
break;
|
||||
case ABI_ARG_EXPAND:
|
||||
case ABI_ARG_DIRECT_SPLIT_STRUCT_I32:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case ABI_ARG_DIRECT_PAIR:
|
||||
case ABI_ARG_IGNORE:
|
||||
case ABI_ARG_DIRECT_COERCE_INT:
|
||||
@@ -5867,7 +5867,7 @@ INLINE void llvm_emit_vasplat_expr(GenContext *c, BEValue *value_ref, Expr *vasp
|
||||
case TYPE_SLICE:
|
||||
return;
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6246,7 +6246,7 @@ static inline void llvm_emit_macro_block(GenContext *c, BEValue *be_value, Expr
|
||||
case VARDECL_REWRAPPED:
|
||||
case VARDECL_ERASE:
|
||||
case VARDECL_BITMEMBER:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case VARDECL_PARAM_CT:
|
||||
case VARDECL_PARAM_CT_TYPE:
|
||||
case VARDECL_PARAM_EXPR:
|
||||
@@ -6375,7 +6375,7 @@ static inline void llvm_emit_vector_initializer_list(GenContext *c, BEValue *val
|
||||
break;
|
||||
case DESIGNATOR_FIELD:
|
||||
default:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6638,9 +6638,9 @@ static inline void llvm_emit_typeid_info(GenContext *c, BEValue *value, Expr *ex
|
||||
return;
|
||||
}
|
||||
case TYPEID_INFO_PARENTOF:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
|
||||
void llvm_emit_try_unwrap_chain(GenContext *c, BEValue *value, Expr *expr)
|
||||
@@ -6779,7 +6779,7 @@ static inline void llvm_emit_builtin_access(GenContext *c, BEValue *be_value, Ex
|
||||
llvm_emit_type_from_any(c, be_value);
|
||||
return;
|
||||
}
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
|
||||
static LLVMValueRef llvm_get_benchmark_hook_global(GenContext *c, Expr *expr)
|
||||
@@ -7109,7 +7109,7 @@ void llvm_emit_expr(GenContext *c, BEValue *value, Expr *expr)
|
||||
case UNRESOLVED_EXPRS:
|
||||
case EXPR_SUBSCRIPT_ASSIGN:
|
||||
// These are folded in the semantic analysis step.
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case EXPR_LAMBDA:
|
||||
case EXPR_COND:
|
||||
case EXPR_ASM:
|
||||
@@ -7119,7 +7119,7 @@ void llvm_emit_expr(GenContext *c, BEValue *value, Expr *expr)
|
||||
case EXPR_NAMED_ARGUMENT:
|
||||
case EXPR_BUILTIN:
|
||||
case EXPR_OPERATOR_CHARS:
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
case EXPR_TWO:
|
||||
llvm_emit_expr(c, value, expr->two_expr.first);
|
||||
llvm_emit_expr(c, value, expr->two_expr.last);
|
||||
@@ -7322,7 +7322,7 @@ void llvm_emit_expr(GenContext *c, BEValue *value, Expr *expr)
|
||||
llvm_emit_bitaccess(c, value, expr);
|
||||
return;
|
||||
}
|
||||
UNREACHABLE
|
||||
UNREACHABLE_VOID
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user