Commit c132b767 by Karl Schimpf

Fix symbol table handling in functions.

Also fixes minor issues with branches in instructions (i.e. defining entry node and computing predecessors). BUG= https://code.google.com/p/nativeclient/issues/detail?id=3892 R=stichnot@chromium.org Review URL: https://codereview.chromium.org/561823002
parent 64dcde7e
...@@ -29,6 +29,11 @@ public: ...@@ -29,6 +29,11 @@ public:
// Access the label number and name for this node. // Access the label number and name for this node.
SizeT getIndex() const { return Number; } SizeT getIndex() const { return Number; }
IceString getName() const; IceString getName() const;
void setName(IceString &NewName) {
// Make sure that the name can only be set once.
assert(Name.empty());
Name = NewName;
}
IceString getAsmName() const { IceString getAsmName() const {
return ".L" + Func->getFunctionName() + "$" + getName(); return ".L" + Func->getFunctionName() + "$" + getName();
} }
......
...@@ -335,6 +335,11 @@ public: ...@@ -335,6 +335,11 @@ public:
SizeT getIndex() const { return Number; } SizeT getIndex() const { return Number; }
IceString getName() const; IceString getName() const;
void setName(IceString &NewName) {
// Make sure that the name can only be set once.
assert(Name.empty());
Name = NewName;
}
Inst *getDefinition() const { return DefInst; } Inst *getDefinition() const { return DefInst; }
void setDefinition(Inst *Inst, const CfgNode *Node); void setDefinition(Inst *Inst, const CfgNode *Node);
...@@ -427,7 +432,7 @@ private: ...@@ -427,7 +432,7 @@ private:
// (bit)vector index for liveness analysis. // (bit)vector index for liveness analysis.
const SizeT Number; const SizeT Number;
// Name is optional. // Name is optional.
const IceString Name; IceString Name;
// DefInst is the instruction that produces this variable as its // DefInst is the instruction that produces this variable as its
// dest. // dest.
Inst *DefInst; Inst *DefInst;
......
...@@ -739,21 +739,27 @@ void GlobalsParser::ProcessRecord() { ...@@ -739,21 +739,27 @@ void GlobalsParser::ProcessRecord() {
installGlobalVar(); installGlobalVar();
} }
// Parses a valuesymtab block in the bitcode file. /// Base class for parsing a valuesymtab block in the bitcode file.
class ValuesymtabParser : public BlockParserBaseClass { class ValuesymtabParser : public BlockParserBaseClass {
typedef SmallString<128> StringType; ValuesymtabParser(const ValuesymtabParser &) LLVM_DELETED_FUNCTION;
void operator=(const ValuesymtabParser &) LLVM_DELETED_FUNCTION;
public: public:
ValuesymtabParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser, ValuesymtabParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser)
bool AllowBbEntries) : BlockParserBaseClass(BlockID, EnclosingParser) {}
: BlockParserBaseClass(BlockID, EnclosingParser),
AllowBbEntries(AllowBbEntries) {}
virtual ~ValuesymtabParser() LLVM_OVERRIDE {} virtual ~ValuesymtabParser() LLVM_OVERRIDE {}
protected:
typedef SmallString<128> StringType;
// Associates Name with the value defined by the given Index.
virtual void setValueName(uint64_t Index, StringType &Name) = 0;
// Associates Name with the value defined by the given Index;
virtual void setBbName(uint64_t Index, StringType &Name) = 0;
private: private:
// True if entries to name basic blocks allowed.
bool AllowBbEntries;
virtual void ProcessRecord() LLVM_OVERRIDE; virtual void ProcessRecord() LLVM_OVERRIDE;
...@@ -774,25 +780,16 @@ void ValuesymtabParser::ProcessRecord() { ...@@ -774,25 +780,16 @@ void ValuesymtabParser::ProcessRecord() {
if (!isValidRecordSizeAtLeast(2, "Valuesymtab value entry")) if (!isValidRecordSizeAtLeast(2, "Valuesymtab value entry"))
return; return;
ConvertToString(ConvertedName); ConvertToString(ConvertedName);
Value *V = Context->getGlobalValueByID(Values[0]); setValueName(Values[0], ConvertedName);
if (V == NULL) {
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
StrBuf << "Invalid global address ID in valuesymtab: " << Values[0];
Error(StrBuf.str());
return;
}
V->setName(StringRef(ConvertedName.data(), ConvertedName.size()));
return; return;
} }
case naclbitc::VST_CODE_BBENTRY: { case naclbitc::VST_CODE_BBENTRY: {
// VST_BBENTRY: [BbId, namechar x N] // VST_BBENTRY: [BbId, namechar x N]
// For now, since we aren't processing function blocks, don't handle. if (!isValidRecordSizeAtLeast(2, "Valuesymtab basic block entry"))
if (AllowBbEntries) { return;
Error("Valuesymtab bb entry not implemented"); ConvertToString(ConvertedName);
setBbName(Values[0], ConvertedName);
return; return;
}
break;
} }
default: default:
break; break;
...@@ -802,10 +799,13 @@ void ValuesymtabParser::ProcessRecord() { ...@@ -802,10 +799,13 @@ void ValuesymtabParser::ProcessRecord() {
return; return;
} }
class FunctionValuesymtabParser;
/// Parses function blocks in the bitcode file. /// Parses function blocks in the bitcode file.
class FunctionParser : public BlockParserBaseClass { class FunctionParser : public BlockParserBaseClass {
FunctionParser(const FunctionParser &) LLVM_DELETED_FUNCTION; FunctionParser(const FunctionParser &) LLVM_DELETED_FUNCTION;
FunctionParser &operator=(const FunctionParser &) LLVM_DELETED_FUNCTION; FunctionParser &operator=(const FunctionParser &) LLVM_DELETED_FUNCTION;
friend class FunctionValuesymtabParser;
public: public:
FunctionParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) FunctionParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser)
...@@ -819,6 +819,7 @@ public: ...@@ -819,6 +819,7 @@ public:
Func->setReturnType(Context->convertToIceType(LLVMFunc->getReturnType())); Func->setReturnType(Context->convertToIceType(LLVMFunc->getReturnType()));
Func->setInternal(LLVMFunc->hasInternalLinkage()); Func->setInternal(LLVMFunc->hasInternalLinkage());
CurrentNode = InstallNextBasicBlock(); CurrentNode = InstallNextBasicBlock();
Func->setEntryNode(CurrentNode);
for (Function::const_arg_iterator ArgI = LLVMFunc->arg_begin(), for (Function::const_arg_iterator ArgI = LLVMFunc->arg_begin(),
ArgE = LLVMFunc->arg_end(); ArgE = LLVMFunc->arg_end();
ArgI != ArgE; ++ArgI) { ArgI != ArgE; ++ArgI) {
...@@ -1293,6 +1294,7 @@ void FunctionParser::ExitBlock() { ...@@ -1293,6 +1294,7 @@ void FunctionParser::ExitBlock() {
Node->appendInst(Ice::InstUnreachable::create(Func)); Node->appendInst(Ice::InstUnreachable::create(Func));
} }
} }
Func->computePredecessors();
// Note: Once any errors have been found, we turn off all // Note: Once any errors have been found, we turn off all
// translation of all remaining functions. This allows use to see // translation of all remaining functions. This allows use to see
// multiple errors, without adding extra checks to the translator // multiple errors, without adding extra checks to the translator
...@@ -1759,15 +1761,80 @@ void ConstantsParser::ProcessRecord() { ...@@ -1759,15 +1761,80 @@ void ConstantsParser::ProcessRecord() {
} }
} }
// Parses valuesymtab blocks appearing in a function block.
class FunctionValuesymtabParser : public ValuesymtabParser {
FunctionValuesymtabParser(const FunctionValuesymtabParser &)
LLVM_DELETED_FUNCTION;
void operator=(const FunctionValuesymtabParser &) LLVM_DELETED_FUNCTION;
public:
FunctionValuesymtabParser(unsigned BlockID, FunctionParser *EnclosingParser)
: ValuesymtabParser(BlockID, EnclosingParser) {}
private:
// Returns the enclosing function parser.
FunctionParser *getFunctionParser() const {
return reinterpret_cast<FunctionParser *>(GetEnclosingParser());
}
virtual void setValueName(uint64_t Index, StringType &Name) LLVM_OVERRIDE;
virtual void setBbName(uint64_t Index, StringType &Name) LLVM_OVERRIDE;
// Reports that the assignment of Name to the value associated with
// index is not possible, for the given Context.
void reportUnableToAssign(const char *Context, uint64_t Index,
StringType &Name) {
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
StrBuf << "Function-local " << Context << " name '" << Name
<< "' can't be associated with index " << Index;
Error(StrBuf.str());
}
};
void FunctionValuesymtabParser::setValueName(uint64_t Index, StringType &Name) {
// Note: We check when Index is too small, so that we can error recover
// (FP->getOperand will create fatal error).
if (Index < getFunctionParser()->CachedNumGlobalValueIDs) {
reportUnableToAssign("instruction", Index, Name);
// TODO(kschimpf) Remove error recovery once implementation complete.
return;
}
Ice::Operand *Op = getFunctionParser()->getOperand(Index);
if (Ice::Variable *V = dyn_cast<Ice::Variable>(Op)) {
std::string Nm(Name.data(), Name.size());
V->setName(Nm);
} else {
reportUnableToAssign("variable", Index, Name);
}
}
void FunctionValuesymtabParser::setBbName(uint64_t Index, StringType &Name) {
if (Index >= getFunctionParser()->Func->getNumNodes()) {
reportUnableToAssign("block", Index, Name);
return;
}
std::string Nm(Name.data(), Name.size());
getFunctionParser()->Func->getNodes()[Index]->setName(Nm);
}
bool FunctionParser::ParseBlock(unsigned BlockID) { bool FunctionParser::ParseBlock(unsigned BlockID) {
switch (BlockID) { switch (BlockID) {
case naclbitc::CONSTANTS_BLOCK_ID: { case naclbitc::CONSTANTS_BLOCK_ID: {
ConstantsParser Parser(BlockID, this); ConstantsParser Parser(BlockID, this);
return Parser.ParseThisBlock(); return Parser.ParseThisBlock();
} }
case naclbitc::VALUE_SYMTAB_BLOCK_ID: {
if (PNaClAllowLocalSymbolTables) {
FunctionValuesymtabParser Parser(BlockID, this);
return Parser.ParseThisBlock();
}
break;
}
default: default:
return BlockParserBaseClass::ParseBlock(BlockID); break;
} }
return BlockParserBaseClass::ParseBlock(BlockID);
} }
/// Parses the module block in the bitcode file. /// Parses the module block in the bitcode file.
...@@ -1784,6 +1851,42 @@ protected: ...@@ -1784,6 +1851,42 @@ protected:
virtual void ProcessRecord() LLVM_OVERRIDE; virtual void ProcessRecord() LLVM_OVERRIDE;
}; };
class ModuleValuesymtabParser : public ValuesymtabParser {
ModuleValuesymtabParser(const ModuleValuesymtabParser &)
LLVM_DELETED_FUNCTION;
void operator=(const ModuleValuesymtabParser &) LLVM_DELETED_FUNCTION;
public:
ModuleValuesymtabParser(unsigned BlockID, ModuleParser *MP)
: ValuesymtabParser(BlockID, MP) {}
virtual ~ModuleValuesymtabParser() LLVM_OVERRIDE {}
private:
virtual void setValueName(uint64_t Index, StringType &Name) LLVM_OVERRIDE;
virtual void setBbName(uint64_t Index, StringType &Name) LLVM_OVERRIDE;
};
void ModuleValuesymtabParser::setValueName(uint64_t Index, StringType &Name) {
Value *V = Context->getGlobalValueByID(Index);
if (V == NULL) {
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
StrBuf << "Invalid global address ID in valuesymtab: " << Index;
Error(StrBuf.str());
return;
}
V->setName(StringRef(Name.data(), Name.size()));
}
void ModuleValuesymtabParser::setBbName(uint64_t Index, StringType &Name) {
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
StrBuf << "Can't define basic block name at global level: '" << Name
<< "' -> " << Index;
Error(StrBuf.str());
}
bool ModuleParser::ParseBlock(unsigned BlockID) LLVM_OVERRIDE { bool ModuleParser::ParseBlock(unsigned BlockID) LLVM_OVERRIDE {
switch (BlockID) { switch (BlockID) {
case naclbitc::BLOCKINFO_BLOCK_ID: case naclbitc::BLOCKINFO_BLOCK_ID:
...@@ -1797,7 +1900,7 @@ bool ModuleParser::ParseBlock(unsigned BlockID) LLVM_OVERRIDE { ...@@ -1797,7 +1900,7 @@ bool ModuleParser::ParseBlock(unsigned BlockID) LLVM_OVERRIDE {
return Parser.ParseThisBlock(); return Parser.ParseThisBlock();
} }
case naclbitc::VALUE_SYMTAB_BLOCK_ID: { case naclbitc::VALUE_SYMTAB_BLOCK_ID: {
ValuesymtabParser Parser(BlockID, this, false); ModuleValuesymtabParser Parser(BlockID, this);
return Parser.ParseThisBlock(); return Parser.ParseThisBlock();
} }
case naclbitc::FUNCTION_BLOCK_ID: { case naclbitc::FUNCTION_BLOCK_ID: {
......
; Test if we can read alloca instructions. ; Test if we can read alloca instructions.
; RUN: llvm-as < %s | pnacl-freeze \ ; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \
; RUN: | %llvm2ice -notranslate -verbose=inst -build-on-read \ ; RUN: | %llvm2ice -notranslate -verbose=inst -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery \ ; RUN: -allow-pnacl-reader-error-recovery \
; RUN: -allow-local-symbol-tables \
; RUN: | FileCheck %s ; RUN: | FileCheck %s
; Show examples where size is defined by a constant. ; Show examples where size is defined by a constant.
define i32 @AllocaA0Size1() { define i32 @AllocaA0Size1() {
entry:
%array = alloca i8, i32 1 %array = alloca i8, i32 1
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__0 = alloca i8, i32 1 ; CHECK-NEXT: %array = alloca i8, i32 1
; CHECK-NEXT: ret i32 %__0 ; CHECK-NEXT: ret i32 %array
} }
define i32 @AllocaA0Size2() { define i32 @AllocaA0Size2() {
entry:
%array = alloca i8, i32 2 %array = alloca i8, i32 2
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__0 = alloca i8, i32 2 ; CHECK-NEXT: %array = alloca i8, i32 2
; CHECK-NEXT: ret i32 %__0 ; CHECK-NEXT: ret i32 %array
} }
define i32 @AllocaA0Size3() { define i32 @AllocaA0Size3() {
entry:
%array = alloca i8, i32 3 %array = alloca i8, i32 3
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__0 = alloca i8, i32 3 ; CHECK-NEXT: %array = alloca i8, i32 3
; CHECK-NEXT: ret i32 %__0 ; CHECK-NEXT: ret i32 %array
} }
define i32 @AllocaA0Size4() { define i32 @AllocaA0Size4() {
entry:
%array = alloca i8, i32 4 %array = alloca i8, i32 4
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__0 = alloca i8, i32 4 ; CHECK-NEXT: %array = alloca i8, i32 4
; CHECK-NEXT: ret i32 %__0 ; CHECK-NEXT: ret i32 %array
} }
define i32 @AllocaA1Size4(i32 %n) { define i32 @AllocaA1Size4(i32 %n) {
entry:
%array = alloca i8, i32 4, align 1 %array = alloca i8, i32 4, align 1
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__1 = alloca i8, i32 4, align 1 ; CHECK-NEXT: %array = alloca i8, i32 4, align 1
; CHECK-NEXT: ret i32 %__1 ; CHECK-NEXT: ret i32 %array
} }
define i32 @AllocaA2Size4(i32 %n) { define i32 @AllocaA2Size4(i32 %n) {
entry:
%array = alloca i8, i32 4, align 2 %array = alloca i8, i32 4, align 2
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__1 = alloca i8, i32 4, align 2 ; CHECK-NEXT: %array = alloca i8, i32 4, align 2
; CHECK-NEXT: ret i32 %__1 ; CHECK-NEXT: ret i32 %array
} }
define i32 @AllocaA8Size4(i32 %n) { define i32 @AllocaA8Size4(i32 %n) {
entry:
%array = alloca i8, i32 4, align 8 %array = alloca i8, i32 4, align 8
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__1 = alloca i8, i32 4, align 8 ; CHECK-NEXT: %array = alloca i8, i32 4, align 8
; CHECK-NEXT: ret i32 %__1 ; CHECK-NEXT: ret i32 %array
} }
define i32 @Alloca16Size4(i32 %n) { define i32 @Alloca16Size4(i32 %n) {
entry:
%array = alloca i8, i32 4, align 16 %array = alloca i8, i32 4, align 16
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__1 = alloca i8, i32 4, align 16 ; CHECK-NEXT: %array = alloca i8, i32 4, align 16
; CHECK-NEXT: ret i32 %__1 ; CHECK-NEXT: ret i32 %array
} }
; Show examples where size is not known at compile time. ; Show examples where size is not known at compile time.
define i32 @AllocaVarsizeA0(i32 %n) { define i32 @AllocaVarsizeA0(i32 %n) {
entry:
%array = alloca i8, i32 %n %array = alloca i8, i32 %n
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__1 = alloca i8, i32 %__0 ; CHECK-NEXT: %array = alloca i8, i32 %n
; CHECK-NEXT: ret i32 %__1 ; CHECK-NEXT: ret i32 %array
} }
define i32 @AllocaVarsizeA1(i32 %n) { define i32 @AllocaVarsizeA1(i32 %n) {
entry:
%array = alloca i8, i32 %n, align 1 %array = alloca i8, i32 %n, align 1
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__1 = alloca i8, i32 %__0, align 1 ; CHECK-NEXT: %array = alloca i8, i32 %n, align 1
; CHECK-NEXT: ret i32 %__1 ; CHECK-NEXT: ret i32 %array
} }
define i32 @AllocaVarsizeA2(i32 %n) { define i32 @AllocaVarsizeA2(i32 %n) {
entry:
%array = alloca i8, i32 %n, align 2 %array = alloca i8, i32 %n, align 2
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__1 = alloca i8, i32 %__0, align 2 ; CHECK-NEXT: %array = alloca i8, i32 %n, align 2
; CHECK-NEXT: ret i32 %__1 ; CHECK-NEXT: ret i32 %array
} }
define i32 @AllocaVarsizeA4(i32 %n) { define i32 @AllocaVarsizeA4(i32 %n) {
entry:
%array = alloca i8, i32 %n, align 4 %array = alloca i8, i32 %n, align 4
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__1 = alloca i8, i32 %__0, align 4 ; CHECK-NEXT: %array = alloca i8, i32 %n, align 4
; CHECK-NEXT: ret i32 %__1 ; CHECK-NEXT: ret i32 %array
} }
define i32 @AllocaVarsizeA8(i32 %n) { define i32 @AllocaVarsizeA8(i32 %n) {
entry:
%array = alloca i8, i32 %n, align 8 %array = alloca i8, i32 %n, align 8
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__1 = alloca i8, i32 %__0, align 8 ; CHECK-NEXT: %array = alloca i8, i32 %n, align 8
; CHECK-NEXT: ret i32 %__1 ; CHECK-NEXT: ret i32 %array
} }
define i32 @AllocaVarsizeA16(i32 %n) { define i32 @AllocaVarsizeA16(i32 %n) {
entry:
%array = alloca i8, i32 %n, align 16 %array = alloca i8, i32 %n, align 16
%addr = ptrtoint i8* %array to i32 %addr = ptrtoint i8* %array to i32
ret i32 %addr ret i32 %addr
; CHECK: __0: ; CHECK: entry:
; CHECK-NEXT: %__1 = alloca i8, i32 %__0, align 16 ; CHECK-NEXT: %array = alloca i8, i32 %n, align 16
; CHECK-NEXT: ret i32 %__1 ; CHECK-NEXT: ret i32 %array
} }
; Tests if we handle a branch instructions. ; Tests if we handle a branch instructions.
; RUN: llvm-as < %s | pnacl-freeze \ ; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \
; RUN: | %llvm2ice -notranslate -verbose=inst -build-on-read \ ; RUN: | %llvm2ice -notranslate -verbose=inst -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery \ ; RUN: -allow-pnacl-reader-error-recovery \
; RUN: -allow-local-symbol-tables \
; RUN: | FileCheck %s ; RUN: | FileCheck %s
define void @SimpleBranch() { define void @SimpleBranch() {
entry:
br label %b3 br label %b3
b1: b1:
br label %b2 br label %b2
...@@ -16,17 +18,18 @@ b3: ...@@ -16,17 +18,18 @@ b3:
} }
; CHECK: define void @SimpleBranch() { ; CHECK: define void @SimpleBranch() {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: br label %__3 ; CHECK-NEXT: br label %b3
; CHECK-NEXT: __1: ; CHECK-NEXT: b1:
; CHECK-NEXT: br label %__2 ; CHECK-NEXT: br label %b2
; CHECK-NEXT: __2: ; CHECK-NEXT: b2:
; CHECK-NEXT: ret void ; CHECK-NEXT: ret void
; CHECK-NEXT: __3: ; CHECK-NEXT: b3:
; CHECK-NEXT: br label %__1 ; CHECK-NEXT: br label %b1
; CHECK-NEXT: } ; CHECK-NEXT: }
define void @CondBranch(i32 %p) { define void @CondBranch(i32 %p) {
entry:
%test = trunc i32 %p to i1 %test = trunc i32 %p to i1
br i1 %test, label %b1, label %b2 br i1 %test, label %b1, label %b2
b1: b1:
...@@ -35,12 +38,12 @@ b2: ...@@ -35,12 +38,12 @@ b2:
br i1 %test, label %b2, label %b1 br i1 %test, label %b2, label %b1
} }
; CHECK-NEXT: define void @CondBranch(i32 %__0) { ; CHECK-NEXT: define void @CondBranch(i32 %p) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__1 = trunc i32 %__0 to i1 ; CHECK-NEXT: %test = trunc i32 %p to i1
; CHECK-NEXT: br i1 %__1, label %__1, label %__2 ; CHECK-NEXT: br i1 %test, label %b1, label %b2
; CHECK-NEXT: __1: ; CHECK-NEXT: b1:
; CHECK-NEXT: ret void ; CHECK-NEXT: ret void
; CHECK-NEXT: __2: ; CHECK-NEXT: b2:
; CHECK-NEXT: br i1 %__1, label %__2, label %__1 ; CHECK-NEXT: br i1 %test, label %b2, label %b1
; CHECK-NEXT: } ; CHECK-NEXT: }
; Test handling of constants in function blocks. ; Test handling of constants in function blocks.
; RUN: llvm-as < %s | pnacl-freeze \ ; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \
; RUN: | %llvm2ice -notranslate -verbose=inst -build-on-read \ ; RUN: | %llvm2ice -notranslate -verbose=inst -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery \ ; RUN: -allow-pnacl-reader-error-recovery \
; RUN: -allow-local-symbol-tables \
; RUN: | FileCheck %s ; RUN: | FileCheck %s
define void @TestIntegers() { define void @TestIntegers() {
; CHECK: __0: entry:
; CHECK: entry:
; Test various sized integers ; Test various sized integers
%v0 = or i1 true, false %v0 = or i1 true, false
; CHECK-NEXT: %__0 = or i1 true, false ; CHECK-NEXT: %v0 = or i1 true, false
%v1 = add i8 0, 0 %v1 = add i8 0, 0
; CHECK-NEXT: %__1 = add i8 0, 0 ; CHECK-NEXT: %v1 = add i8 0, 0
%v2 = add i8 5, 0 %v2 = add i8 5, 0
; CHECK-NEXT: %__2 = add i8 5, 0 ; CHECK-NEXT: %v2 = add i8 5, 0
%v3 = add i8 -5, 0 %v3 = add i8 -5, 0
; CHECK-NEXT: %__3 = add i8 -5, 0 ; CHECK-NEXT: %v3 = add i8 -5, 0
%v4 = and i16 10, 0 %v4 = and i16 10, 0
; CHECK-NEXT: %__4 = and i16 10, 0 ; CHECK-NEXT: %v4 = and i16 10, 0
%v5 = add i16 -10, 0 %v5 = add i16 -10, 0
; CHECK-NEXT: %__5 = add i16 -10, 0 ; CHECK-NEXT: %v5 = add i16 -10, 0
%v6 = add i32 20, 0 %v6 = add i32 20, 0
; CHECK-NEXT: %__6 = add i32 20, 0 ; CHECK-NEXT: %v6 = add i32 20, 0
%v7 = add i32 -20, 0 %v7 = add i32 -20, 0
; CHECK-NEXT: %__7 = add i32 -20, 0 ; CHECK-NEXT: %v7 = add i32 -20, 0
%v8 = add i64 30, 0 %v8 = add i64 30, 0
; CHECK-NEXT: %__8 = add i64 30, 0 ; CHECK-NEXT: %v8 = add i64 30, 0
%v9 = add i64 -30, 0 %v9 = add i64 -30, 0
; CHECK-NEXT: %__9 = add i64 -30, 0 ; CHECK-NEXT: %v9 = add i64 -30, 0
; Test undefined integer values. ; Test undefined integer values.
%v10 = xor i1 undef, false %v10 = xor i1 undef, false
; CHECK-NEXT: %__10 = xor i1 undef, false ; CHECK-NEXT: %v10 = xor i1 undef, false
%v11 = add i8 undef, 0 %v11 = add i8 undef, 0
; CHECK-NEXT: %__11 = add i8 undef, 0 ; CHECK-NEXT: %v11 = add i8 undef, 0
%v12 = add i16 undef, 0 %v12 = add i16 undef, 0
; CHECK-NEXT: %__12 = add i16 undef, 0 ; CHECK-NEXT: %v12 = add i16 undef, 0
%v13 = add i32 undef, 0 %v13 = add i32 undef, 0
; CHECK-NEXT: %__13 = add i32 undef, 0 ; CHECK-NEXT: %v13 = add i32 undef, 0
%v14 = add i64 undef, 0 %v14 = add i64 undef, 0
; CHECK-NEXT: %__14 = add i64 undef, 0 ; CHECK-NEXT: %v14 = add i64 undef, 0
ret void ret void
; CHECK-NEXT: ret void ; CHECK-NEXT: ret void
...@@ -61,94 +63,95 @@ define void @TestIntegers() { ...@@ -61,94 +63,95 @@ define void @TestIntegers() {
} }
define void @TestFloats() { define void @TestFloats() {
; CHECK: __0: entry:
; CHECK: entry:
; Test float and double constants ; Test float and double constants
%v0 = fadd float 1.0, 0.0 %v0 = fadd float 1.0, 0.0
; CHECK-NEXT: %__0 = fadd float 1.000000e+00, 0.000000e+00 ; CHECK-NEXT: %v0 = fadd float 1.000000e+00, 0.000000e+00
%v1 = fadd double 1.0, 0.0 %v1 = fadd double 1.0, 0.0
; CHECK-NEXT: %__1 = fadd double 1.000000e+00, 0.000000e+00 ; CHECK-NEXT: %v1 = fadd double 1.000000e+00, 0.000000e+00
%v2 = fsub float 7.000000e+00, 8.000000e+00 %v2 = fsub float 7.000000e+00, 8.000000e+00
; CHECK-NEXT: %__2 = fsub float 7.000000e+00, 8.000000e+00 ; CHECK-NEXT: %v2 = fsub float 7.000000e+00, 8.000000e+00
%v3 = fsub double 5.000000e+00, 6.000000e+00 %v3 = fsub double 5.000000e+00, 6.000000e+00
; CHECK-NEXT: %__3 = fsub double 5.000000e+00, 6.000000e+00 ; CHECK-NEXT: %v3 = fsub double 5.000000e+00, 6.000000e+00
; Test undefined float and double. ; Test undefined float and double.
%v4 = fadd float undef, 0.0 %v4 = fadd float undef, 0.0
; CHECK-NEXT: %__4 = fadd float undef, 0.000000e+00 ; CHECK-NEXT: %v4 = fadd float undef, 0.000000e+00
%v5 = fsub double undef, 6.000000e+00 %v5 = fsub double undef, 6.000000e+00
; CHECK-NEXT: %__5 = fsub double undef, 6.000000e+00 ; CHECK-NEXT: %v5 = fsub double undef, 6.000000e+00
; Test special floating point constants. Note: LLVM assembly appears ; Test special floating point constants. Note: LLVM assembly appears
; to use 64-bit integer constants for both float and double. ; to use 64-bit integer constants for both float and double.
; Generated from NAN in <math.h> ; Generated from NAN in <math.h>
%v6 = fadd float 0x7FF8000000000000, 0.0 %v6 = fadd float 0x7FF8000000000000, 0.0
; CHECK-NEXT: %__6 = fadd float nan, 0.000000e+00 ; CHECK-NEXT: %v6 = fadd float nan, 0.000000e+00
; Generated from -NAN in <math.h> ; Generated from -NAN in <math.h>
%v7 = fadd float 0xFFF8000000000000, 0.0 %v7 = fadd float 0xFFF8000000000000, 0.0
; CHECK-NEXT: %__7 = fadd float -nan, 0.000000e+00 ; CHECK-NEXT: %v7 = fadd float -nan, 0.000000e+00
; Generated from INFINITY in <math.h> ; Generated from INFINITY in <math.h>
%v8 = fadd float 0x7FF0000000000000, 0.0 %v8 = fadd float 0x7FF0000000000000, 0.0
; CHECK-NEXT: %__8 = fadd float inf, 0.000000e+00 ; CHECK-NEXT: %v8 = fadd float inf, 0.000000e+00
; Generated from -INFINITY in <math.h> ; Generated from -INFINITY in <math.h>
%v9 = fadd float 0xFFF0000000000000, 0.0 %v9 = fadd float 0xFFF0000000000000, 0.0
; CHECK-NEXT: %__9 = fadd float -inf, 0.000000e+00 ; CHECK-NEXT: %v9 = fadd float -inf, 0.000000e+00
; Generated from FLT_MIN in <float.h> ; Generated from FLT_MIN in <float.h>
%v10 = fadd float 0x381000000000000000, 0.0 %v10 = fadd float 0x381000000000000000, 0.0
; CHECK-NEXT: %__10 = fadd float 0.000000e+00, 0.000000e+00 ; CHECK-NEXT: %v10 = fadd float 0.000000e+00, 0.000000e+00
; Generated from -FLT_MIN in <float.h> ; Generated from -FLT_MIN in <float.h>
%v11 = fadd float 0xb81000000000000000, 0.0 %v11 = fadd float 0xb81000000000000000, 0.0
; CHECK-NEXT: %__11 = fadd float 0.000000e+00, 0.000000e+00 ; CHECK-NEXT: %v11 = fadd float 0.000000e+00, 0.000000e+00
; Generated from FLT_MAX in <float.h> ; Generated from FLT_MAX in <float.h>
%v12 = fadd float 340282346638528859811704183484516925440.000000, 0.0 %v12 = fadd float 340282346638528859811704183484516925440.000000, 0.0
; CHECK-NEXT: %__12 = fadd float 3.402823e+38, 0.000000e+00 ; CHECK-NEXT: %v12 = fadd float 3.402823e+38, 0.000000e+00
; Generated from -FLT_MAX in <float.h> ; Generated from -FLT_MAX in <float.h>
%v13 = fadd float -340282346638528859811704183484516925440.000000, 0.0 %v13 = fadd float -340282346638528859811704183484516925440.000000, 0.0
; CHECK-NEXT: %__13 = fadd float -3.402823e+38, 0.000000e+00 ; CHECK-NEXT: %v13 = fadd float -3.402823e+38, 0.000000e+00
; Generated from NAN in <math.h> ; Generated from NAN in <math.h>
%v14 = fadd double 0x7FF8000000000000, 0.0 %v14 = fadd double 0x7FF8000000000000, 0.0
; CHECK-NEXT: %__14 = fadd double nan, 0.000000e+00 ; CHECK-NEXT: %v14 = fadd double nan, 0.000000e+00
; Generated from -NAN in <math.h> ; Generated from -NAN in <math.h>
%v15 = fadd double 0xFFF8000000000000, 0.0 %v15 = fadd double 0xFFF8000000000000, 0.0
; CHECK-NEXT: %__15 = fadd double -nan, 0.000000e+00 ; CHECK-NEXT: %v15 = fadd double -nan, 0.000000e+00
; Generated from INFINITY in <math.h> ; Generated from INFINITY in <math.h>
%v16 = fadd double 0x7FF0000000000000, 0.0 %v16 = fadd double 0x7FF0000000000000, 0.0
; CHECK-NEXT: %__16 = fadd double inf, 0.000000e+00 ; CHECK-NEXT: %v16 = fadd double inf, 0.000000e+00
; Generated from -INFINITY in <math.h> ; Generated from -INFINITY in <math.h>
%v17 = fadd double 0xFFF0000000000000, 0.0 %v17 = fadd double 0xFFF0000000000000, 0.0
; CHECK-NEXT: %__17 = fadd double -inf, 0.000000e+00 ; CHECK-NEXT: %v17 = fadd double -inf, 0.000000e+00
; Generated from DBL_MIN in <float.h> ; Generated from DBL_MIN in <float.h>
%v18 = fadd double 0x0010000000000000, 0.0 %v18 = fadd double 0x0010000000000000, 0.0
; CHECK-NEXT: %__18 = fadd double 2.225074e-308, 0.000000e+00 ; CHECK-NEXT: %v18 = fadd double 2.225074e-308, 0.000000e+00
; Generated from -DBL_MIN in <float.h> ; Generated from -DBL_MIN in <float.h>
%v19 = fadd double 0x8010000000000000, 0.0 %v19 = fadd double 0x8010000000000000, 0.0
; CHECK-NEXT: %__19 = fadd double -2.225074e-308, 0.000000e+00 ; CHECK-NEXT: %v19 = fadd double -2.225074e-308, 0.000000e+00
; Generated from DBL_MAX in <float.h> ; Generated from DBL_MAX in <float.h>
%v20 = fadd double 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000, 0.0 %v20 = fadd double 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000, 0.0
; CHECK-NEXT: %__20 = fadd double 1.797693e+308, 0.000000e+00 ; CHECK-NEXT: %v20 = fadd double 1.797693e+308, 0.000000e+00
; Generated from -DBL_MAX in <float.h> ; Generated from -DBL_MAX in <float.h>
%v21 = fadd double -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000, 0.0 %v21 = fadd double -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000, 0.0
; CHECK-NEXT: %__21 = fadd double -1.797693e+308, 0.000000e+00 ; CHECK-NEXT: %v21 = fadd double -1.797693e+308, 0.000000e+00
ret void ret void
; CHECK-NEXT: ret void ; CHECK-NEXT: ret void
......
; Tests insertelement and extractelement vector instructions. ; Tests insertelement and extractelement vector instructions.
; RUN: llvm-as < %s | pnacl-freeze \ ; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \
; RUN: | %llvm2ice -notranslate -verbose=inst -build-on-read \ ; RUN: | %llvm2ice -notranslate -verbose=inst -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery \ ; RUN: -allow-pnacl-reader-error-recovery \
; RUN: -allow-local-symbol-tables \
; RUN: | FileCheck %s ; RUN: | FileCheck %s
; TODO(kschimpf): Change index arguments to valid constant indices once ; TODO(kschimpf): Change index arguments to valid constant indices once
; we can handle constants. ; we can handle constants.
define void @ExtractV4xi1(<4 x i1> %v, i32 %i) { define void @ExtractV4xi1(<4 x i1> %v, i32 %i) {
entry:
%e = extractelement <4 x i1> %v, i32 %i %e = extractelement <4 x i1> %v, i32 %i
ret void ret void
} }
; CHECK: define void @ExtractV4xi1(<4 x i1> %__0, i32 %__1) { ; CHECK: define void @ExtractV4xi1(<4 x i1> %v, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__2 = extractelement <4 x i1> %__0, i32 %__1 ; CHECK-NEXT: %e = extractelement <4 x i1> %v, i32 %i
; CHECK-NEXT: ret void ; CHECK-NEXT: ret void
; CHECK-NEXT: } ; CHECK-NEXT: }
define void @ExtractV8xi1(<8 x i1> %v, i32 %i) { define void @ExtractV8xi1(<8 x i1> %v, i32 %i) {
entry:
%e = extractelement <8 x i1> %v, i32 %i %e = extractelement <8 x i1> %v, i32 %i
ret void ret void
} }
; CHECK-NEXT: define void @ExtractV8xi1(<8 x i1> %__0, i32 %__1) { ; CHECK-NEXT: define void @ExtractV8xi1(<8 x i1> %v, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__2 = extractelement <8 x i1> %__0, i32 %__1 ; CHECK-NEXT: %e = extractelement <8 x i1> %v, i32 %i
; CHECK-NEXT: ret void ; CHECK-NEXT: ret void
; CHECK-NEXT: } ; CHECK-NEXT: }
define void @ExtractV16xi1(<16 x i1> %v, i32 %i) { define void @ExtractV16xi1(<16 x i1> %v, i32 %i) {
entry:
%e = extractelement <16 x i1> %v, i32 %i %e = extractelement <16 x i1> %v, i32 %i
ret void ret void
} }
; CHECK-NEXT: define void @ExtractV16xi1(<16 x i1> %__0, i32 %__1) { ; CHECK-NEXT: define void @ExtractV16xi1(<16 x i1> %v, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__2 = extractelement <16 x i1> %__0, i32 %__1 ; CHECK-NEXT: %e = extractelement <16 x i1> %v, i32 %i
; CHECK-NEXT: ret void ; CHECK-NEXT: ret void
; CHECK-NEXT: } ; CHECK-NEXT: }
define void @ExtractV16xi8(<16 x i8> %v, i32 %i) { define void @ExtractV16xi8(<16 x i8> %v, i32 %i) {
entry:
%e = extractelement <16 x i8> %v, i32 %i %e = extractelement <16 x i8> %v, i32 %i
ret void ret void
} }
; CHECK-NEXT: define void @ExtractV16xi8(<16 x i8> %__0, i32 %__1) { ; CHECK-NEXT: define void @ExtractV16xi8(<16 x i8> %v, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__2 = extractelement <16 x i8> %__0, i32 %__1 ; CHECK-NEXT: %e = extractelement <16 x i8> %v, i32 %i
; CHECK-NEXT: ret void ; CHECK-NEXT: ret void
; CHECK-NEXT: } ; CHECK-NEXT: }
define void @ExtractV8xi16(<8 x i16> %v, i32 %i) { define void @ExtractV8xi16(<8 x i16> %v, i32 %i) {
entry:
%e = extractelement <8 x i16> %v, i32 %i %e = extractelement <8 x i16> %v, i32 %i
ret void ret void
} }
; CHECK-NEXT: define void @ExtractV8xi16(<8 x i16> %__0, i32 %__1) { ; CHECK-NEXT: define void @ExtractV8xi16(<8 x i16> %v, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__2 = extractelement <8 x i16> %__0, i32 %__1 ; CHECK-NEXT: %e = extractelement <8 x i16> %v, i32 %i
; CHECK-NEXT: ret void ; CHECK-NEXT: ret void
; CHECK-NEXT: } ; CHECK-NEXT: }
define i32 @ExtractV4xi32(<4 x i32> %v, i32 %i) { define i32 @ExtractV4xi32(<4 x i32> %v, i32 %i) {
entry:
%e = extractelement <4 x i32> %v, i32 %i %e = extractelement <4 x i32> %v, i32 %i
ret i32 %e ret i32 %e
} }
; CHECK-NEXT: define i32 @ExtractV4xi32(<4 x i32> %__0, i32 %__1) { ; CHECK-NEXT: define i32 @ExtractV4xi32(<4 x i32> %v, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__2 = extractelement <4 x i32> %__0, i32 %__1 ; CHECK-NEXT: %e = extractelement <4 x i32> %v, i32 %i
; CHECK-NEXT: ret i32 %__2 ; CHECK-NEXT: ret i32 %e
; CHECK-NEXT: } ; CHECK-NEXT: }
define float @ExtractV4xfloat(<4 x float> %v, i32 %i) { define float @ExtractV4xfloat(<4 x float> %v, i32 %i) {
entry:
%e = extractelement <4 x float> %v, i32 %i %e = extractelement <4 x float> %v, i32 %i
ret float %e ret float %e
} }
; CHECK-NEXT: define float @ExtractV4xfloat(<4 x float> %__0, i32 %__1) { ; CHECK-NEXT: define float @ExtractV4xfloat(<4 x float> %v, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__2 = extractelement <4 x float> %__0, i32 %__1 ; CHECK-NEXT: %e = extractelement <4 x float> %v, i32 %i
; CHECK-NEXT: ret float %__2 ; CHECK-NEXT: ret float %e
; CHECK-NEXT: } ; CHECK-NEXT: }
define <4 x i1> @InsertV4xi1(<4 x i1> %v, i32 %pe, i32 %i) { define <4 x i1> @InsertV4xi1(<4 x i1> %v, i32 %pe, i32 %i) {
entry:
%e = trunc i32 %pe to i1 %e = trunc i32 %pe to i1
%r = insertelement <4 x i1> %v, i1 %e, i32 %i %r = insertelement <4 x i1> %v, i1 %e, i32 %i
ret <4 x i1> %r ret <4 x i1> %r
} }
; CHECK-NEXT: define <4 x i1> @InsertV4xi1(<4 x i1> %__0, i32 %__1, i32 %__2) { ; CHECK-NEXT: define <4 x i1> @InsertV4xi1(<4 x i1> %v, i32 %pe, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__3 = trunc i32 %__1 to i1 ; CHECK-NEXT: %e = trunc i32 %pe to i1
; CHECK-NEXT: %__4 = insertelement <4 x i1> %__0, i1 %__3, i32 %__2 ; CHECK-NEXT: %r = insertelement <4 x i1> %v, i1 %e, i32 %i
; CHECK-NEXT: ret i1 %__4 ; CHECK-NEXT: ret i1 %r
; CHECK-NEXT: } ; CHECK-NEXT: }
define <8 x i1> @InsertV8xi1(<8 x i1> %v, i32 %pe, i32 %i) { define <8 x i1> @InsertV8xi1(<8 x i1> %v, i32 %pe, i32 %i) {
entry:
%e = trunc i32 %pe to i1 %e = trunc i32 %pe to i1
%r = insertelement <8 x i1> %v, i1 %e, i32 %i %r = insertelement <8 x i1> %v, i1 %e, i32 %i
ret <8 x i1> %r ret <8 x i1> %r
} }
; CHECK-NEXT: define <8 x i1> @InsertV8xi1(<8 x i1> %__0, i32 %__1, i32 %__2) { ; CHECK-NEXT: define <8 x i1> @InsertV8xi1(<8 x i1> %v, i32 %pe, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__3 = trunc i32 %__1 to i1 ; CHECK-NEXT: %e = trunc i32 %pe to i1
; CHECK-NEXT: %__4 = insertelement <8 x i1> %__0, i1 %__3, i32 %__2 ; CHECK-NEXT: %r = insertelement <8 x i1> %v, i1 %e, i32 %i
; CHECK-NEXT: ret i1 %__4 ; CHECK-NEXT: ret i1 %r
; CHECK-NEXT: } ; CHECK-NEXT: }
define <16 x i1> @InsertV16xi1(<16 x i1> %v, i32 %pe, i32 %i) { define <16 x i1> @InsertV16xi1(<16 x i1> %v, i32 %pe, i32 %i) {
entry:
%e = trunc i32 %pe to i1 %e = trunc i32 %pe to i1
%r = insertelement <16 x i1> %v, i1 %e, i32 %i %r = insertelement <16 x i1> %v, i1 %e, i32 %i
ret <16 x i1> %r ret <16 x i1> %r
} }
; CHECK-NEXT: define <16 x i1> @InsertV16xi1(<16 x i1> %__0, i32 %__1, i32 %__2) { ; CHECK-NEXT: define <16 x i1> @InsertV16xi1(<16 x i1> %v, i32 %pe, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__3 = trunc i32 %__1 to i1 ; CHECK-NEXT: %e = trunc i32 %pe to i1
; CHECK-NEXT: %__4 = insertelement <16 x i1> %__0, i1 %__3, i32 %__2 ; CHECK-NEXT: %r = insertelement <16 x i1> %v, i1 %e, i32 %i
; CHECK-NEXT: ret i1 %__4 ; CHECK-NEXT: ret i1 %r
; CHECK-NEXT: } ; CHECK-NEXT: }
define <16 x i8> @InsertV16xi8(<16 x i8> %v, i32 %pe, i32 %i) { define <16 x i8> @InsertV16xi8(<16 x i8> %v, i32 %pe, i32 %i) {
entry:
%e = trunc i32 %pe to i8 %e = trunc i32 %pe to i8
%r = insertelement <16 x i8> %v, i8 %e, i32 %i %r = insertelement <16 x i8> %v, i8 %e, i32 %i
ret <16 x i8> %r ret <16 x i8> %r
} }
; CHECK-NEXT: define <16 x i8> @InsertV16xi8(<16 x i8> %__0, i32 %__1, i32 %__2) { ; CHECK-NEXT: define <16 x i8> @InsertV16xi8(<16 x i8> %v, i32 %pe, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__3 = trunc i32 %__1 to i8 ; CHECK-NEXT: %e = trunc i32 %pe to i8
; CHECK-NEXT: %__4 = insertelement <16 x i8> %__0, i8 %__3, i32 %__2 ; CHECK-NEXT: %r = insertelement <16 x i8> %v, i8 %e, i32 %i
; CHECK-NEXT: ret i8 %__4 ; CHECK-NEXT: ret i8 %r
; CHECK-NEXT: } ; CHECK-NEXT: }
define <8 x i16> @InsertV8xi16(<8 x i16> %v, i32 %pe, i32 %i) { define <8 x i16> @InsertV8xi16(<8 x i16> %v, i32 %pe, i32 %i) {
entry:
%e = trunc i32 %pe to i16 %e = trunc i32 %pe to i16
%r = insertelement <8 x i16> %v, i16 %e, i32 %i %r = insertelement <8 x i16> %v, i16 %e, i32 %i
ret <8 x i16> %r ret <8 x i16> %r
} }
; CHECK-NEXT: define <8 x i16> @InsertV8xi16(<8 x i16> %__0, i32 %__1, i32 %__2) { ; CHECK-NEXT: define <8 x i16> @InsertV8xi16(<8 x i16> %v, i32 %pe, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__3 = trunc i32 %__1 to i16 ; CHECK-NEXT: %e = trunc i32 %pe to i16
; CHECK-NEXT: %__4 = insertelement <8 x i16> %__0, i16 %__3, i32 %__2 ; CHECK-NEXT: %r = insertelement <8 x i16> %v, i16 %e, i32 %i
; CHECK-NEXT: ret i16 %__4 ; CHECK-NEXT: ret i16 %r
; CHECK-NEXT: } ; CHECK-NEXT: }
define <4 x i32> @InsertV16xi32(<4 x i32> %v, i32 %e, i32 %i) { define <4 x i32> @InsertV4xi32(<4 x i32> %v, i32 %e, i32 %i) {
entry:
%r = insertelement <4 x i32> %v, i32 %e, i32 %i %r = insertelement <4 x i32> %v, i32 %e, i32 %i
ret <4 x i32> %r ret <4 x i32> %r
} }
; CHECK-NEXT: define <4 x i32> @InsertV16xi32(<4 x i32> %__0, i32 %__1, i32 %__2) { ; CHECK-NEXT: define <4 x i32> @InsertV4xi32(<4 x i32> %v, i32 %e, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__3 = insertelement <4 x i32> %__0, i32 %__1, i32 %__2 ; CHECK-NEXT: %r = insertelement <4 x i32> %v, i32 %e, i32 %i
; CHECK-NEXT: ret i32 %__3 ; CHECK-NEXT: ret i32 %r
; CHECK-NEXT: } ; CHECK-NEXT: }
define <4 x float> @InsertV16xfloat(<4 x float> %v, float %e, i32 %i) { define <4 x float> @InsertV4xfloat(<4 x float> %v, float %e, i32 %i) {
entry:
%r = insertelement <4 x float> %v, float %e, i32 %i %r = insertelement <4 x float> %v, float %e, i32 %i
ret <4 x float> %r ret <4 x float> %r
} }
; CHECK-NEXT: define <4 x float> @InsertV16xfloat(<4 x float> %__0, float %__1, i32 %__2) { ; CHECK-NEXT: define <4 x float> @InsertV4xfloat(<4 x float> %v, float %e, i32 %i) {
; CHECK-NEXT: __0: ; CHECK-NEXT: entry:
; CHECK-NEXT: %__3 = insertelement <4 x float> %__0, float %__1, i32 %__2 ; CHECK-NEXT: %r = insertelement <4 x float> %v, float %e, i32 %i
; CHECK-NEXT: ret float %__3 ; CHECK-NEXT: ret float %r
; CHECK-NEXT: } ; CHECK-NEXT: }
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