| ... | @@ -8094,33 +8094,32 @@ static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *n | ... | @@ -8094,33 +8094,32 @@ static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *n |
| 8094 | case 64: | 8094 | case 64: |
| 8095 | return LLVMConstReal(get_llvm_type(g, type_entry), const_val->data.x_f64); | 8095 | return LLVMConstReal(get_llvm_type(g, type_entry), const_val->data.x_f64); |
| 8096 | case 80: { | 8096 | case 80: { |
| 8097 | LLVMTypeRef llvm_i80 = LLVMIntType(80); | 8097 | uint64_t buf[2]; |
| 8098 | LLVMValueRef x; | 8098 | memcpy(&buf, &const_val->data.x_f80, 16); |
| 8099 | if (g->is_big_endian) { | 8099 | #if ZIG_BYTE_ORDER == ZIG_BIG_ENDIAN |
| 8100 | x = LLVMConstInt(llvm_i80, const_val->data.x_f80.signExp, false); | 8100 | uint64_t tmp = buf[0]; |
| 8101 | x = LLVMConstShl(x, LLVMConstInt(llvm_i80, 64, false)); | 8101 | buf[0] = buf[1]; |
| 8102 | x = LLVMConstOr(x, LLVMConstInt(llvm_i80, const_val->data.x_f80.signif, false)); | 8102 | buf[1] = tmp; |
| 8103 | } else { | 8103 | #endif |
| 8104 | x = LLVMConstInt(llvm_i80, const_val->data.x_f80.signif, false); | 8104 | LLVMValueRef as_i128 = LLVMConstIntOfArbitraryPrecision(LLVMInt128Type(), 2, buf); |
| 8105 | x = LLVMConstShl(x, LLVMConstInt(llvm_i80, 16, false)); | 8105 | LLVMValueRef as_int = LLVMConstTrunc(as_i128, LLVMIntType(80)); |
| 8106 | x = LLVMConstOr(x, LLVMConstInt(llvm_i80, const_val->data.x_f80.signExp, false)); | 8106 | return LLVMConstBitCast(as_int, get_llvm_type(g, type_entry)); |
| 8107 | } | | |
| 8108 | return LLVMConstBitCast(x, get_llvm_type(g, type_entry)); | | |
| 8109 | } | 8107 | } |
| 8110 | case 128: | 8108 | case 128: |
| 8111 | { | 8109 | { |
| 8112 | uint64_t buf[2]; | 8110 | uint64_t buf[2]; |
| 8113 | | 8111 | |
| 8114 | // LLVM seems to require that the lower half of the f128 be placed first in the buffer. | 8112 | // LLVM seems to require that the lower half of the f128 be |
| 8115 | #if defined(ZIG_BYTE_ORDER) && ZIG_BYTE_ORDER == ZIG_LITTLE_ENDIAN | 8113 | // placed first in the buffer. |
| 8116 | buf[0] = const_val->data.x_f128.v[0]; | 8114 | #if ZIG_BYTE_ORDER == ZIG_LITTLE_ENDIAN |
| 8117 | buf[1] = const_val->data.x_f128.v[1]; | 8115 | buf[0] = const_val->data.x_f128.v[0]; |
| 8118 | #elif defined(ZIG_BYTE_ORDER) && ZIG_BYTE_ORDER == ZIG_BIG_ENDIAN | 8116 | buf[1] = const_val->data.x_f128.v[1]; |
| 8119 | buf[0] = const_val->data.x_f128.v[1]; | 8117 | #elif ZIG_BYTE_ORDER == ZIG_BIG_ENDIAN |
| 8120 | buf[1] = const_val->data.x_f128.v[0]; | 8118 | buf[0] = const_val->data.x_f128.v[1]; |
| 8121 | #else | 8119 | buf[1] = const_val->data.x_f128.v[0]; |
| 8122 | #error Unsupported endian | 8120 | #else |
| 8123 | #endif | 8121 | #error Unsupported endian |
| | 8122 | #endif |
| 8124 | | 8123 | |
| 8125 | LLVMValueRef as_int = LLVMConstIntOfArbitraryPrecision(LLVMInt128Type(), 2, buf); | 8124 | LLVMValueRef as_int = LLVMConstIntOfArbitraryPrecision(LLVMInt128Type(), 2, buf); |
| 8126 | return LLVMConstBitCast(as_int, get_llvm_type(g, type_entry)); | 8125 | return LLVMConstBitCast(as_int, get_llvm_type(g, type_entry)); |