Running clang-format on alloy.

All except x64_sequences, which needs work.
This commit is contained in:
Ben Vanik
2014-07-10 20:20:00 -07:00
parent 0158380cfc
commit 7daa85179c
139 changed files with 6925 additions and 6998 deletions

View File

@@ -13,11 +13,9 @@
#include <alloy/frontend/ppc/ppc_instr_tables.h>
using namespace alloy;
using namespace alloy::frontend;
using namespace alloy::frontend::ppc;
namespace alloy {
namespace frontend {
namespace ppc {
void InstrOperand::Dump(std::string& out_str) {
if (display) {
@@ -92,21 +90,18 @@ void InstrOperand::Dump(std::string& out_str) {
out_str += buffer;
}
void InstrAccessBits::Clear() {
spr = cr = gpr = fpr = 0;
}
void InstrAccessBits::Clear() { spr = cr = gpr = fpr = 0; }
void InstrAccessBits::Extend(InstrAccessBits& other) {
spr |= other.spr;
cr |= other.cr;
gpr |= other.gpr;
fpr |= other.fpr;
vr31_0 |= other.vr31_0;
vr63_32 |= other.vr63_32;
vr95_64 |= other.vr95_64;
vr127_96 |= other.vr127_96;
}
spr |= other.spr;
cr |= other.cr;
gpr |= other.gpr;
fpr |= other.fpr;
vr31_0 |= other.vr31_0;
vr63_32 |= other.vr63_32;
vr95_64 |= other.vr95_64;
vr127_96 |= other.vr127_96;
}
void InstrAccessBits::MarkAccess(InstrRegister& reg) {
uint64_t bits = 0;
@@ -128,7 +123,7 @@ void InstrAccessBits::MarkAccess(InstrRegister& reg) {
spr |= bits << (2 * 2);
break;
case InstrRegister::kCR:
cr |= bits << (2 * reg.ordinal);
cr |= bits << (2 * reg.ordinal);
break;
case InstrRegister::kFPSCR:
spr |= bits << (2 * 3);
@@ -281,41 +276,31 @@ void InstrAccessBits::Dump(std::string& out_str) {
out_str = str.str();
}
void InstrDisasm::Init(const char* name, const char* info, uint32_t flags) {
this->name = name;
this->info = info;
this->flags = flags;
}
void InstrDisasm::AddLR(InstrRegister::Access access) {
}
void InstrDisasm::AddLR(InstrRegister::Access access) {}
void InstrDisasm::AddCTR(InstrRegister::Access access) {
}
void InstrDisasm::AddCTR(InstrRegister::Access access) {}
void InstrDisasm::AddCR(uint32_t bf, InstrRegister::Access access) {
}
void InstrDisasm::AddCR(uint32_t bf, InstrRegister::Access access) {}
void InstrDisasm::AddFPSCR(InstrRegister::Access access) {
}
void InstrDisasm::AddFPSCR(InstrRegister::Access access) {}
void InstrDisasm::AddRegOperand(
InstrRegister::RegisterSet set, uint32_t ordinal,
InstrRegister::Access access, const char* display) {
}
void InstrDisasm::AddRegOperand(InstrRegister::RegisterSet set,
uint32_t ordinal, InstrRegister::Access access,
const char* display) {}
void InstrDisasm::AddSImmOperand(uint64_t value, size_t width,
const char* display) {
}
const char* display) {}
void InstrDisasm::AddUImmOperand(uint64_t value, size_t width,
const char* display) {
}
const char* display) {}
int InstrDisasm::Finish() {
return 0;
}
int InstrDisasm::Finish() { return 0; }
void InstrDisasm::Dump(std::string& out_str, size_t pad) {
out_str = name;
@@ -330,47 +315,55 @@ void InstrDisasm::Dump(std::string& out_str, size_t pad) {
}
}
InstrType* alloy::frontend::ppc::GetInstrType(uint32_t code) {
InstrType* GetInstrType(uint32_t code) {
// Fast lookup via tables.
InstrType* slot = NULL;
switch (code >> 26) {
case 4:
// Opcode = 4, index = bits 10-0 (10)
slot = alloy::frontend::ppc::tables::instr_table_4[XESELECTBITS(code, 0, 10)];
break;
case 19:
// Opcode = 19, index = bits 10-1 (10)
slot = alloy::frontend::ppc::tables::instr_table_19[XESELECTBITS(code, 1, 10)];
break;
case 30:
// Opcode = 30, index = bits 4-1 (4)
// Special cased to an uber instruction.
slot = alloy::frontend::ppc::tables::instr_table_30[XESELECTBITS(code, 0, 0)];
break;
case 31:
// Opcode = 31, index = bits 10-1 (10)
slot = alloy::frontend::ppc::tables::instr_table_31[XESELECTBITS(code, 1, 10)];
break;
case 58:
// Opcode = 58, index = bits 1-0 (2)
slot = alloy::frontend::ppc::tables::instr_table_58[XESELECTBITS(code, 0, 1)];
break;
case 59:
// Opcode = 59, index = bits 5-1 (5)
slot = alloy::frontend::ppc::tables::instr_table_59[XESELECTBITS(code, 1, 5)];
break;
case 62:
// Opcode = 62, index = bits 1-0 (2)
slot = alloy::frontend::ppc::tables::instr_table_62[XESELECTBITS(code, 0, 1)];
break;
case 63:
// Opcode = 63, index = bits 10-1 (10)
slot = alloy::frontend::ppc::tables::instr_table_63[XESELECTBITS(code, 1, 10)];
break;
default:
slot = alloy::frontend::ppc::tables::instr_table[XESELECTBITS(code, 26, 31)];
break;
case 4:
// Opcode = 4, index = bits 10-0 (10)
slot = alloy::frontend::ppc::tables::instr_table_4[XESELECTBITS(code, 0,
10)];
break;
case 19:
// Opcode = 19, index = bits 10-1 (10)
slot = alloy::frontend::ppc::tables::instr_table_19[XESELECTBITS(code, 1,
10)];
break;
case 30:
// Opcode = 30, index = bits 4-1 (4)
// Special cased to an uber instruction.
slot = alloy::frontend::ppc::tables::instr_table_30[XESELECTBITS(code, 0,
0)];
break;
case 31:
// Opcode = 31, index = bits 10-1 (10)
slot = alloy::frontend::ppc::tables::instr_table_31[XESELECTBITS(code, 1,
10)];
break;
case 58:
// Opcode = 58, index = bits 1-0 (2)
slot = alloy::frontend::ppc::tables::instr_table_58[XESELECTBITS(code, 0,
1)];
break;
case 59:
// Opcode = 59, index = bits 5-1 (5)
slot = alloy::frontend::ppc::tables::instr_table_59[XESELECTBITS(code, 1,
5)];
break;
case 62:
// Opcode = 62, index = bits 1-0 (2)
slot = alloy::frontend::ppc::tables::instr_table_62[XESELECTBITS(code, 0,
1)];
break;
case 63:
// Opcode = 63, index = bits 10-1 (10)
slot = alloy::frontend::ppc::tables::instr_table_63[XESELECTBITS(code, 1,
10)];
break;
default:
slot =
alloy::frontend::ppc::tables::instr_table[XESELECTBITS(code, 26, 31)];
break;
}
if (slot && slot->opcode) {
return slot;
@@ -379,8 +372,7 @@ InstrType* alloy::frontend::ppc::GetInstrType(uint32_t code) {
// Slow lookup via linear scan.
// This is primarily due to laziness. It could be made fast like the others.
for (size_t n = 0;
n < XECOUNT(alloy::frontend::ppc::tables::instr_table_scan);
n++) {
n < XECOUNT(alloy::frontend::ppc::tables::instr_table_scan); n++) {
slot = &(alloy::frontend::ppc::tables::instr_table_scan[n]);
if (slot->opcode == (code & slot->opcode_mask)) {
return slot;
@@ -390,7 +382,7 @@ InstrType* alloy::frontend::ppc::GetInstrType(uint32_t code) {
return NULL;
}
int alloy::frontend::ppc::RegisterInstrEmit(uint32_t code, InstrEmitFn emit) {
int RegisterInstrEmit(uint32_t code, InstrEmitFn emit) {
InstrType* instr_type = GetInstrType(code);
XEASSERTNOTNULL(instr_type);
if (!instr_type) {
@@ -400,3 +392,7 @@ int alloy::frontend::ppc::RegisterInstrEmit(uint32_t code, InstrEmitFn emit) {
instr_type->emit = emit;
return 0;
}
} // namespace ppc
} // namespace frontend
} // namespace alloy