Cleaning up build warnings.

This commit is contained in:
Ben Vanik 2013-01-29 20:27:24 -08:00
parent 80d74dbe03
commit f117f870fb
7 changed files with 101 additions and 24 deletions

65
TODO.md
View File

@ -1,24 +1,71 @@
## Loader
Set all function variable addresses to the thunks. Since we handle the thunks
specially the variables are just used as function pointer storage.
## Kernel ## Kernel
NtAllocateVirtualMemory Ordered:
```
RtlInitializeCriticalSection/RtlInitializeCriticalSectionAndSpinCount
RtlEnterCriticalSection/RtlLeaveCriticalSection
XexCheckExecutablePrivilege
XGetAVPack
ExGetXConfigSetting
KeTlsAlloc
KeTlsSetValue
```
Others:
```
NtQueryVirtualMemory
KeTlsAlloc/KeTlsFree/KeTlsGetValue/KeTlsSetValue
NtWaitForSingleObjectEx
RtlInitUnicodeString/RtlFreeUnicodeString
RtlInitAnsiString/RtlFreeAnsiString
RtlUnicodeStringToAnsiString
RtlCompareMemoryUlong
RtlNtStatusToDosError
RtlRaiseException
NtCreateFile/NtOpenFile
NtReadFile/NtReadFileScatter
NtQueryFullAttributesFile
NtQueryInformationFile/NtSetInformationFile
NtQueryDirectoryFile/NtQueryVolumeInformationFile
NtDuplicateObject
KeBugCheck:
// VOID
// _In_ ULONG BugCheckCode
```
## Instructions ## Instructions
### XER CA bit (carry)
Not sure the way I'm doing this is right. addic/subficx/etc set it to the value
of the overflow bit from the LLVM *_with_overflow intrinsic.
``` ```
rlwimix rlwimix
rldiclx rldiclx
``` ```
### XER CA bit (carry)
Not sure the way I'm doing this is right. addic/subficx/etc set it to the value
of the overflow bit from the LLVM *_with_overflow intrinsic.
### Overflow
Overflow bits can be set via the intrinsics: Overflow bits can be set via the intrinsics:
`llvm.sadd.with.overflow`/etc `llvm.sadd.with.overflow`/etc
It'd be nice to avoid doing this unless absolutely required. The SDB could It'd be nice to avoid doing this unless absolutely required. The SDB could
walk functions to see if they ever read or branch on the SO bit of things. walk functions to see if they ever read or branch on the SO bit of things.
### Conditions
Condition bits are, after each function: Condition bits are, after each function:
``` ```
if (target_reg < 0) { CR0 = b100 | XER[SO] } if (target_reg < 0) { CR0 = b100 | XER[SO] }
@ -31,9 +78,15 @@ For those, it would be nice to remove redundant sets. Maybe LLVM will do it
automatically due to the local cr? May need to split that up into a few locals automatically due to the local cr? May need to split that up into a few locals
(one for each bit?) to ensure deduping. (one for each bit?) to ensure deduping.
### Branch Hinting
`@llvm.expect.i32`/`.i64` could be used with the BH bits in branches to `@llvm.expect.i32`/`.i64` could be used with the BH bits in branches to
indicate expected values. indicate expected values.
### Data Caching
dcbt and dcbtst could use LLVM intrinsic @llvm.prefetch.
## Codegen ## Codegen
### Calling convention ### Calling convention

View File

@ -12,7 +12,7 @@
# LLVM paths. # LLVM paths.
# TODO(benvanik): switch based on configuration. # TODO(benvanik): switch based on configuration.
'llvm_path': 'build/llvm/debug/', 'llvm_path': 'build/llvm/release/',
'llvm_config': '<(llvm_path)bin/llvm-config', 'llvm_config': '<(llvm_path)bin/llvm-config',
}, },
@ -101,6 +101,7 @@
'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES', 'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES',
'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES', 'GCC_WARN_ABOUT_MISSING_NEWLINE': 'YES',
'WARNING_CFLAGS': ['-Wall', '-Wendif-labels'], 'WARNING_CFLAGS': ['-Wall', '-Wendif-labels'],
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',
}, },
}, },
} }

View File

@ -91,7 +91,7 @@ public:
private: private:
void GenerateSharedBlocks(); void GenerateSharedBlocks();
void PrepareBasicBlock(sdb::FunctionBlock* block); int PrepareBasicBlock(sdb::FunctionBlock* block);
void GenerateBasicBlock(sdb::FunctionBlock* block); void GenerateBasicBlock(sdb::FunctionBlock* block);
void SetupLocals(); void SetupLocals();

View File

@ -13,7 +13,7 @@ fi
--memory_address_verification=true \ --memory_address_verification=true \
--trace_kernel_calls=true \ --trace_kernel_calls=true \
--trace_user_calls=true \ --trace_user_calls=true \
--trace_instructions=true \ --trace_instructions=false \
--abort_before_entry=true \ --abort_before_entry=true \
1>build/run.txt 1>build/run.txt
#2>build/run.llvm.txt \ #2>build/run.llvm.txt \

View File

@ -152,7 +152,7 @@ void FunctionGenerator::GenerateBasicBlocks() {
for (std::map<uint32_t, FunctionBlock*>::iterator it = fn_->blocks.begin(); for (std::map<uint32_t, FunctionBlock*>::iterator it = fn_->blocks.begin();
it != fn_->blocks.end(); ++it) { it != fn_->blocks.end(); ++it) {
FunctionBlock* block = it->second; FunctionBlock* block = it->second;
PrepareBasicBlock(block); XEIGNORE(PrepareBasicBlock(block));
} }
// Setup all local variables now that we know what we need. // Setup all local variables now that we know what we need.
@ -217,7 +217,7 @@ void FunctionGenerator::GenerateSharedBlocks() {
} }
} }
void FunctionGenerator::PrepareBasicBlock(FunctionBlock* block) { int FunctionGenerator::PrepareBasicBlock(FunctionBlock* block) {
// Create the basic block that will end up getting filled during // Create the basic block that will end up getting filled during
// generation. // generation.
char name[32]; char name[32];
@ -247,7 +247,11 @@ void FunctionGenerator::PrepareBasicBlock(FunctionBlock* block) {
// and haven't implemented the disassemble method yet. // and haven't implemented the disassemble method yet.
ppc::InstrDisasm d; ppc::InstrDisasm d;
XEASSERTNOTNULL(i.type->disassemble); XEASSERTNOTNULL(i.type->disassemble);
XEASSERTZERO(i.type->disassemble(i, d)); int result_code = i.type->disassemble(i, d);
XEASSERTZERO(result_code);
if (result_code) {
return result_code;
}
// Accumulate access bits. // Accumulate access bits.
access_bits.Extend(d.access_bits); access_bits.Extend(d.access_bits);
@ -255,6 +259,8 @@ void FunctionGenerator::PrepareBasicBlock(FunctionBlock* block) {
// Add in access bits to function access bits. // Add in access bits to function access bits.
access_bits_.Extend(access_bits); access_bits_.Extend(access_bits);
return 0;
} }
void FunctionGenerator::GenerateBasicBlock(FunctionBlock* block) { void FunctionGenerator::GenerateBasicBlock(FunctionBlock* block) {

View File

@ -245,28 +245,46 @@ void XeIndirectBranch(xe_ppc_state_t* state, uint64_t target, uint64_t br_ia) {
} }
void XeInvalidInstruction(xe_ppc_state_t* state, uint32_t cia, uint32_t data) { void XeInvalidInstruction(xe_ppc_state_t* state, uint32_t cia, uint32_t data) {
// TODO(benvanik): handle better ppc::InstrData i;
XELOGCPU("INVALID INSTRUCTION %.8X %.8X", cia, data); i.address = cia;
i.code = data;
i.type = ppc::GetInstrType(i.code);
if (!i.type) {
XELOGCPU(XT("INVALID INSTRUCTION %.8X: %.8X ???"),
i.address, i.code);
} else if (i.type->disassemble) {
ppc::InstrDisasm d;
i.type->disassemble(i, d);
std::string disasm;
d.Dump(disasm);
XELOGCPU(XT("INVALID INSTRUCTION %.8X: %.8X %s"),
i.address, i.code, disasm.c_str());
} else {
XELOGCPU(XT("INVALID INSTRUCTION %.8X: %.8X %s"),
i.address, i.code, i.type->name);
}
} }
void XeTraceKernelCall(xe_ppc_state_t* state, uint64_t cia, uint64_t call_ia, void XeTraceKernelCall(xe_ppc_state_t* state, uint64_t cia, uint64_t call_ia,
KernelExport* kernel_export) { KernelExport* kernel_export) {
XELOGCPU("TRACE: %.8X -> k.%.8X (%s)", (uint32_t)call_ia - 4, (uint32_t)cia, XELOGCPU(XT("TRACE: %.8X -> k.%.8X (%s)"),
(uint32_t)call_ia - 4, (uint32_t)cia,
kernel_export ? kernel_export->name : "unknown"); kernel_export ? kernel_export->name : "unknown");
} }
void XeTraceUserCall(xe_ppc_state_t* state, uint64_t cia, uint64_t call_ia, void XeTraceUserCall(xe_ppc_state_t* state, uint64_t cia, uint64_t call_ia,
FunctionSymbol* fn) { FunctionSymbol* fn) {
XELOGCPU("TRACE: %.8X -> u.%.8X (%s)", (uint32_t)call_ia - 4, (uint32_t)cia, XELOGCPU(XT("TRACE: %.8X -> u.%.8X (%s)"),
fn->name); (uint32_t)call_ia - 4, (uint32_t)cia, fn->name);
} }
void XeTraceInstruction(xe_ppc_state_t* state, uint32_t cia, uint32_t data) { void XeTraceInstruction(xe_ppc_state_t* state, uint32_t cia, uint32_t data) {
ppc::InstrType* type = ppc::GetInstrType(data); ppc::InstrType* type = ppc::GetInstrType(data);
XELOGCPU("TRACE: %.8X %.8X %s %s", XELOGCPU(XT("TRACE: %.8X %.8X %s %s"),
cia, data, cia, data,
type && type->emit ? " " : "X", type && type->emit ? " " : "X",
type ? type->name : "<unknown>"); type ? type->name : "<unknown>");
// TODO(benvanik): better disassembly, printing of current register values/etc // TODO(benvanik): better disassembly, printing of current register values/etc
} }

View File

@ -85,13 +85,12 @@
}], }],
['_type=="executable"', { ['_type=="executable"', {
'libraries': [ 'libraries': [
'<!@(<(llvm_config) --ldflags)', #'<!@(<(llvm_config) --libs all)',
'<!@(<(llvm_config) --libs all)',
], ],
'library_dirs': [ 'library_dirs': [
# NOTE: this doesn't actually do anything... # NOTE: this doesn't actually do anything...
# http://code.google.com/p/gyp/issues/detail?id=130 # http://code.google.com/p/gyp/issues/detail?id=130
'<!@(<(llvm_config) --libdir)', #'<!@(<(llvm_config) --libdir)',
], ],
'xcode_settings': { 'xcode_settings': {
'OTHER_LDFLAGS': [ 'OTHER_LDFLAGS': [