Mostly fixing up alloy clang build.
This commit is contained in:
@@ -9,10 +9,11 @@
|
||||
|
||||
#include <alloy/backend/x64/x64_code_cache.h>
|
||||
|
||||
#include <poly/assert.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <poly/assert.h>
|
||||
#include <poly/math.h>
|
||||
|
||||
namespace alloy {
|
||||
namespace backend {
|
||||
namespace x64 {
|
||||
@@ -51,7 +52,7 @@ void* X64CodeCache::PlaceCode(void* machine_code, size_t code_size,
|
||||
|
||||
// Always move the code to land on 16b alignment. We do this by rounding up
|
||||
// to 16b so that all offsets are aligned.
|
||||
code_size = XEROUNDUP(code_size, 16);
|
||||
code_size = poly::round_up(code_size, 16);
|
||||
|
||||
lock_.lock();
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ int X64Emitter::Emit(HIRBuilder* builder, size_t& out_stack_size) {
|
||||
}
|
||||
// Ensure 16b alignment.
|
||||
stack_offset -= StackLayout::GUEST_STACK_SIZE;
|
||||
stack_offset = poly::align(stack_offset, 16ull);
|
||||
stack_offset = poly::align(stack_offset, static_cast<size_t>(16));
|
||||
|
||||
// Function prolog.
|
||||
// Must be 16b aligned.
|
||||
@@ -242,7 +242,7 @@ void X64Emitter::EmitTraceSource(const Instr* instr) {
|
||||
uint8_t dest_reg_1 = instr->flags >> 8;
|
||||
|
||||
xdb::protocol::EventType event_type;
|
||||
size_t event_size;
|
||||
size_t event_size = 0;
|
||||
if (dest_reg_0 == 100) {
|
||||
event_type = xdb::protocol::EventType::INSTR;
|
||||
event_size = sizeof(xdb::protocol::InstrEvent);
|
||||
@@ -269,6 +269,7 @@ void X64Emitter::EmitTraceSource(const Instr* instr) {
|
||||
event_size = sizeof(xdb::protocol::InstrEventR8R8);
|
||||
}
|
||||
}
|
||||
assert_not_zero(event_size);
|
||||
|
||||
mov(rax, trace_base);
|
||||
mov(r8d, static_cast<uint32_t>(event_size));
|
||||
@@ -289,6 +290,7 @@ void X64Emitter::EmitTraceSource(const Instr* instr) {
|
||||
mov(word[r8 + 2], ax);
|
||||
|
||||
switch (event_type) {
|
||||
default:
|
||||
case xdb::protocol::EventType::INSTR:
|
||||
break;
|
||||
case xdb::protocol::EventType::INSTR_R8:
|
||||
@@ -330,8 +332,7 @@ void X64Emitter::EmitTraceSourceAppendValue(const Value* value,
|
||||
|
||||
void X64Emitter::EmitGetCurrentThreadId() {
|
||||
// rcx must point to context. We could fetch from the stack if needed.
|
||||
mov(ax,
|
||||
word[rcx + runtime_->frontend()->context_info()->thread_id_offset()]);
|
||||
mov(ax, word[rcx + runtime_->frontend()->context_info()->thread_id_offset()]);
|
||||
}
|
||||
|
||||
void X64Emitter::EmitTraceUserCallReturn() {
|
||||
@@ -345,7 +346,7 @@ void X64Emitter::EmitTraceUserCallReturn() {
|
||||
lock();
|
||||
xadd(qword[rax], r8);
|
||||
mov(rax, static_cast<uint64_t>(xdb::protocol::EventType::USER_CALL_RETURN) |
|
||||
(static_cast<uint64_t>(0) << 8) | (0ull << 32));
|
||||
(static_cast<uint64_t>(0) << 8) | (0ull << 32));
|
||||
mov(qword[r8], rax);
|
||||
EmitGetCurrentThreadId();
|
||||
mov(word[r8 + 2], ax);
|
||||
@@ -645,8 +646,6 @@ void X64Emitter::CallExtern(const hir::Instr* instr,
|
||||
static_cast<uint32_t>(sizeof(xdb::protocol::KernelCallReturnEvent)));
|
||||
lock();
|
||||
xadd(qword[rax], r8);
|
||||
uint32_t module_id = 0;
|
||||
uint32_t ordinal = 0;
|
||||
mov(rax,
|
||||
static_cast<uint64_t>(xdb::protocol::EventType::KERNEL_CALL_RETURN) |
|
||||
(static_cast<uint64_t>(0) << 8) | (0));
|
||||
|
||||
@@ -4491,26 +4491,24 @@ EMITTER_OPCODE_TABLE(
|
||||
// TODO(benvanik): AVX512 has a native variable rotate (rolv).
|
||||
EMITTER(VECTOR_ROTATE_LEFT_V128, MATCH(I<OPCODE_VECTOR_ROTATE_LEFT, V128<>, V128<>, V128<>>)) {
|
||||
static __m128i EmulateVectorRotateLeftI8(__m128i src1, __m128i src2) {
|
||||
alignas(16) __m128i value;
|
||||
alignas(16) __m128i shamt;
|
||||
_mm_store_si128(&value, src1);
|
||||
_mm_store_si128(&shamt, src2);
|
||||
alignas(16) uint8_t value[16];
|
||||
alignas(16) uint8_t shamt[16];
|
||||
_mm_store_si128(reinterpret_cast<__m128i*>(&value), src1);
|
||||
_mm_store_si128(reinterpret_cast<__m128i*>(&shamt), src2);
|
||||
for (size_t i = 0; i < 16; ++i) {
|
||||
value.m128i_u8[i] = poly::rotate_left<uint8_t>(
|
||||
value.m128i_u8[i], shamt.m128i_u8[i] & 0x3);
|
||||
value[i] = poly::rotate_left<uint8_t>(value[i], shamt[i] & 0x3);
|
||||
}
|
||||
return _mm_load_si128(&value);
|
||||
return _mm_load_si128(reinterpret_cast<__m128i*>(&value));
|
||||
}
|
||||
static __m128i EmulateVectorRotateLeftI16(__m128i src1, __m128i src2) {
|
||||
alignas(16) __m128i value;
|
||||
alignas(16) __m128i shamt;
|
||||
_mm_store_si128(&value, src1);
|
||||
_mm_store_si128(&shamt, src2);
|
||||
alignas(16) uint16_t value[8];
|
||||
alignas(16) uint16_t shamt[8];
|
||||
_mm_store_si128(reinterpret_cast<__m128i*>(&value), src1);
|
||||
_mm_store_si128(reinterpret_cast<__m128i*>(&shamt), src2);
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
value.m128i_u16[i] = poly::rotate_left<uint16_t>(
|
||||
value.m128i_u16[i], shamt.m128i_u16[i] & 0xF);
|
||||
value[i] = poly::rotate_left<uint16_t>(value[i], shamt[i] & 0xF);
|
||||
}
|
||||
return _mm_load_si128(&value);
|
||||
return _mm_load_si128(reinterpret_cast<__m128i*>(&value));
|
||||
}
|
||||
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
||||
switch (i.instr->flags) {
|
||||
|
||||
Reference in New Issue
Block a user