Commit 87852e1d by Nicolas Capens

Match sub-vector load/store operand order to regular load/store.

Bug swiftshader:27 Change-Id: Ic116a804fed80222ad9a41f219c937f28104f225 Reviewed-on: https://swiftshader-review.googlesource.com/8271Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent a29d653e
...@@ -113,7 +113,7 @@ namespace sw ...@@ -113,7 +113,7 @@ namespace sw
{ {
return reinterpret_cast<const SectionHeader*>((intptr_t)elfHeader + elfHeader->e_shoff); return reinterpret_cast<const SectionHeader*>((intptr_t)elfHeader + elfHeader->e_shoff);
} }
inline const SectionHeader *elfSection(const ElfHeader *elfHeader, int index) inline const SectionHeader *elfSection(const ElfHeader *elfHeader, int index)
{ {
return &sectionHeader(elfHeader)[index]; return &sectionHeader(elfHeader)[index];
...@@ -122,25 +122,25 @@ namespace sw ...@@ -122,25 +122,25 @@ namespace sw
static void *relocateSymbol(const ElfHeader *elfHeader, const Elf32_Rel &relocation, const SectionHeader &relocationTable) static void *relocateSymbol(const ElfHeader *elfHeader, const Elf32_Rel &relocation, const SectionHeader &relocationTable)
{ {
const SectionHeader *target = elfSection(elfHeader, relocationTable.sh_info); const SectionHeader *target = elfSection(elfHeader, relocationTable.sh_info);
intptr_t address = (intptr_t)elfHeader + target->sh_offset; intptr_t address = (intptr_t)elfHeader + target->sh_offset;
int32_t *patchSite = (int*)(address + relocation.r_offset); int32_t *patchSite = (int*)(address + relocation.r_offset);
uint32_t index = relocation.getSymbol(); uint32_t index = relocation.getSymbol();
int table = relocationTable.sh_link; int table = relocationTable.sh_link;
void *symbolValue = nullptr; void *symbolValue = nullptr;
if(index != SHN_UNDEF) if(index != SHN_UNDEF)
{ {
if(table == SHN_UNDEF) return nullptr; if(table == SHN_UNDEF) return nullptr;
const SectionHeader *symbolTable = elfSection(elfHeader, table); const SectionHeader *symbolTable = elfSection(elfHeader, table);
uint32_t symtab_entries = symbolTable->sh_size / symbolTable->sh_entsize; uint32_t symtab_entries = symbolTable->sh_size / symbolTable->sh_entsize;
if(index >= symtab_entries) if(index >= symtab_entries)
{ {
assert(index < symtab_entries && "Symbol Index out of range"); assert(index < symtab_entries && "Symbol Index out of range");
return nullptr; return nullptr;
} }
intptr_t symbolAddress = (intptr_t)elfHeader + symbolTable->sh_offset; intptr_t symbolAddress = (intptr_t)elfHeader + symbolTable->sh_offset;
Elf32_Sym &symbol = ((Elf32_Sym*)symbolAddress)[index]; Elf32_Sym &symbol = ((Elf32_Sym*)symbolAddress)[index];
uint16_t section = symbol.st_shndx; uint16_t section = symbol.st_shndx;
...@@ -178,7 +178,7 @@ namespace sw ...@@ -178,7 +178,7 @@ namespace sw
static void *relocateSymbol(const ElfHeader *elfHeader, const Elf64_Rela &relocation, const SectionHeader &relocationTable) static void *relocateSymbol(const ElfHeader *elfHeader, const Elf64_Rela &relocation, const SectionHeader &relocationTable)
{ {
const SectionHeader *target = elfSection(elfHeader, relocationTable.sh_info); const SectionHeader *target = elfSection(elfHeader, relocationTable.sh_info);
intptr_t address = (intptr_t)elfHeader + target->sh_offset; intptr_t address = (intptr_t)elfHeader + target->sh_offset;
int32_t *patchSite = (int*)(address + relocation.r_offset); int32_t *patchSite = (int*)(address + relocation.r_offset);
uint32_t index = relocation.getSymbol(); uint32_t index = relocation.getSymbol();
...@@ -189,14 +189,14 @@ namespace sw ...@@ -189,14 +189,14 @@ namespace sw
{ {
if(table == SHN_UNDEF) return nullptr; if(table == SHN_UNDEF) return nullptr;
const SectionHeader *symbolTable = elfSection(elfHeader, table); const SectionHeader *symbolTable = elfSection(elfHeader, table);
uint32_t symtab_entries = symbolTable->sh_size / symbolTable->sh_entsize; uint32_t symtab_entries = symbolTable->sh_size / symbolTable->sh_entsize;
if(index >= symtab_entries) if(index >= symtab_entries)
{ {
assert(index < symtab_entries && "Symbol Index out of range"); assert(index < symtab_entries && "Symbol Index out of range");
return nullptr; return nullptr;
} }
intptr_t symbolAddress = (intptr_t)elfHeader + symbolTable->sh_offset; intptr_t symbolAddress = (intptr_t)elfHeader + symbolTable->sh_offset;
Elf64_Sym &symbol = ((Elf64_Sym*)symbolAddress)[index]; Elf64_Sym &symbol = ((Elf64_Sym*)symbolAddress)[index];
uint16_t section = symbol.st_shndx; uint16_t section = symbol.st_shndx;
...@@ -685,8 +685,8 @@ namespace sw ...@@ -685,8 +685,8 @@ namespace sw
const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::LoadSubVector, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F}; const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::LoadSubVector, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
auto target = ::context->getConstantUndef(Ice::IceType_i32); auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto load = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic); auto load = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
load->addArg(::context->getConstantInt32(4));
load->addArg(ptr); load->addArg(ptr);
load->addArg(::context->getConstantInt32(4));
::basicBlock->appendInst(load); ::basicBlock->appendInst(load);
} }
break; break;
...@@ -698,8 +698,8 @@ namespace sw ...@@ -698,8 +698,8 @@ namespace sw
const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::LoadSubVector, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F}; const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::LoadSubVector, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
auto target = ::context->getConstantUndef(Ice::IceType_i32); auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto load = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic); auto load = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
load->addArg(::context->getConstantInt32(8));
load->addArg(ptr); load->addArg(ptr);
load->addArg(::context->getConstantInt32(8));
::basicBlock->appendInst(load); ::basicBlock->appendInst(load);
} }
break; break;
...@@ -729,9 +729,9 @@ namespace sw ...@@ -729,9 +729,9 @@ namespace sw
const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::StoreSubVector, Ice::Intrinsics::SideEffects_T, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_T}; const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::StoreSubVector, Ice::Intrinsics::SideEffects_T, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_T};
auto target = ::context->getConstantUndef(Ice::IceType_i32); auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto store = Ice::InstIntrinsicCall::create(::function, 3, nullptr, target, intrinsic); auto store = Ice::InstIntrinsicCall::create(::function, 3, nullptr, target, intrinsic);
store->addArg(::context->getConstantInt32(4));
store->addArg(value); store->addArg(value);
store->addArg(ptr); store->addArg(ptr);
store->addArg(::context->getConstantInt32(4));
::basicBlock->appendInst(store); ::basicBlock->appendInst(store);
} }
break; break;
...@@ -743,9 +743,9 @@ namespace sw ...@@ -743,9 +743,9 @@ namespace sw
const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::StoreSubVector, Ice::Intrinsics::SideEffects_T, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_T}; const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::StoreSubVector, Ice::Intrinsics::SideEffects_T, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_T};
auto target = ::context->getConstantUndef(Ice::IceType_i32); auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto store = Ice::InstIntrinsicCall::create(::function, 3, nullptr, target, intrinsic); auto store = Ice::InstIntrinsicCall::create(::function, 3, nullptr, target, intrinsic);
store->addArg(::context->getConstantInt32(8));
store->addArg(value); store->addArg(value);
store->addArg(ptr); store->addArg(ptr);
store->addArg(::context->getConstantInt32(8));
::basicBlock->appendInst(store); ::basicBlock->appendInst(store);
} }
break; break;
...@@ -1245,7 +1245,7 @@ namespace sw ...@@ -1245,7 +1245,7 @@ namespace sw
variableDeclaration->setAlignment(alignment); variableDeclaration->setAlignment(alignment);
variableDeclaration->setIsConstant(true); variableDeclaration->setIsConstant(true);
variableDeclaration->addInitializer(dataInitializer); variableDeclaration->addInitializer(dataInitializer);
::function->addGlobal(variableDeclaration); ::function->addGlobal(variableDeclaration);
constexpr int32_t offset = 0; constexpr int32_t offset = 0;
......
pnacl-subzero @ a29da906
Subproject commit 83425dec5ecae21e092a9a440845ce99a13ded69 Subproject commit a29da906bf910a32de3a81ef43d6ec43f138f2ab
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment