Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
149afc39
Commit
149afc39
authored
Aug 14, 2018
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: More corrections of <id> versus "immediate" operands.
parent
228e964b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
7 deletions
+34
-7
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+0
-0
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+24
-5
SpvBuilder.h
SPIRV/SpvBuilder.h
+2
-1
spvIR.h
SPIRV/spvIR.h
+8
-1
No files found.
SPIRV/GlslangToSpv.cpp
View file @
149afc39
This diff is collapsed.
Click to expand it.
SPIRV/SpvBuilder.cpp
View file @
149afc39
...
...
@@ -81,6 +81,7 @@ Id Builder::import(const char* name)
{
Instruction
*
import
=
new
Instruction
(
getUniqueId
(),
NoType
,
OpExtInstImport
);
import
->
addStringOperand
(
name
);
module
.
mapInstruction
(
import
);
imports
.
push_back
(
std
::
unique_ptr
<
Instruction
>
(
import
));
return
import
->
getResultId
();
...
...
@@ -1331,7 +1332,7 @@ void Builder::createNoResultOp(Op opCode)
buildPoint
->
addInstruction
(
std
::
unique_ptr
<
Instruction
>
(
op
));
}
// An opcode that has one operand, no result id, and no type
// An opcode that has one
id
operand, no result id, and no type
void
Builder
::
createNoResultOp
(
Op
opCode
,
Id
operand
)
{
Instruction
*
op
=
new
Instruction
(
opCode
);
...
...
@@ -1339,12 +1340,16 @@ void Builder::createNoResultOp(Op opCode, Id operand)
buildPoint
->
addInstruction
(
std
::
unique_ptr
<
Instruction
>
(
op
));
}
// An opcode that has
one operand
, no result id, and no type
void
Builder
::
createNoResultOp
(
Op
opCode
,
const
std
::
vector
<
Id
>&
operands
)
// An opcode that has
multiple operands
, no result id, and no type
void
Builder
::
createNoResultOp
(
Op
opCode
,
const
std
::
vector
<
Id
Immediate
>&
operands
)
{
Instruction
*
op
=
new
Instruction
(
opCode
);
for
(
auto
it
=
operands
.
cbegin
();
it
!=
operands
.
cend
();
++
it
)
op
->
addIdOperand
(
*
it
);
for
(
auto
it
=
operands
.
cbegin
();
it
!=
operands
.
cend
();
++
it
)
{
if
(
it
->
isId
)
op
->
addIdOperand
(
it
->
word
);
else
op
->
addImmediateOperand
(
it
->
word
);
}
buildPoint
->
addInstruction
(
std
::
unique_ptr
<
Instruction
>
(
op
));
}
...
...
@@ -1428,6 +1433,20 @@ Id Builder::createOp(Op opCode, Id typeId, const std::vector<Id>& operands)
return
op
->
getResultId
();
}
Id
Builder
::
createOp
(
Op
opCode
,
Id
typeId
,
const
std
::
vector
<
IdImmediate
>&
operands
)
{
Instruction
*
op
=
new
Instruction
(
getUniqueId
(),
typeId
,
opCode
);
for
(
auto
it
=
operands
.
cbegin
();
it
!=
operands
.
cend
();
++
it
)
{
if
(
it
->
isId
)
op
->
addIdOperand
(
it
->
word
);
else
op
->
addImmediateOperand
(
it
->
word
);
}
buildPoint
->
addInstruction
(
std
::
unique_ptr
<
Instruction
>
(
op
));
return
op
->
getResultId
();
}
Id
Builder
::
createSpecConstantOp
(
Op
opCode
,
Id
typeId
,
const
std
::
vector
<
Id
>&
operands
,
const
std
::
vector
<
unsigned
>&
literals
)
{
Instruction
*
op
=
new
Instruction
(
getUniqueId
(),
typeId
,
OpSpecConstantOp
);
...
...
SPIRV/SpvBuilder.h
View file @
149afc39
...
...
@@ -295,13 +295,14 @@ public:
void
createNoResultOp
(
Op
);
void
createNoResultOp
(
Op
,
Id
operand
);
void
createNoResultOp
(
Op
,
const
std
::
vector
<
Id
>&
operands
);
void
createNoResultOp
(
Op
,
const
std
::
vector
<
Id
Immediate
>&
operands
);
void
createControlBarrier
(
Scope
execution
,
Scope
memory
,
MemorySemanticsMask
);
void
createMemoryBarrier
(
unsigned
executionScope
,
unsigned
memorySemantics
);
Id
createUnaryOp
(
Op
,
Id
typeId
,
Id
operand
);
Id
createBinOp
(
Op
,
Id
typeId
,
Id
operand1
,
Id
operand2
);
Id
createTriOp
(
Op
,
Id
typeId
,
Id
operand1
,
Id
operand2
,
Id
operand3
);
Id
createOp
(
Op
,
Id
typeId
,
const
std
::
vector
<
Id
>&
operands
);
Id
createOp
(
Op
,
Id
typeId
,
const
std
::
vector
<
IdImmediate
>&
operands
);
Id
createFunctionCall
(
spv
::
Function
*
,
const
std
::
vector
<
spv
::
Id
>&
);
Id
createSpecConstantOp
(
Op
,
Id
typeId
,
const
std
::
vector
<
spv
::
Id
>&
operands
,
const
std
::
vector
<
unsigned
>&
literals
);
...
...
SPIRV/spvIR.h
View file @
149afc39
...
...
@@ -79,6 +79,11 @@ const MemorySemanticsMask MemorySemanticsAllMemory =
MemorySemanticsAtomicCounterMemoryMask
|
MemorySemanticsImageMemoryMask
);
struct
IdImmediate
{
bool
isId
;
// true if word is an Id, false if word is an immediate
unsigned
word
;
};
//
// SPIR-V IR instruction.
//
...
...
@@ -349,7 +354,9 @@ public:
Instruction
*
getInstruction
(
Id
id
)
const
{
return
idToInstruction
[
id
];
}
const
std
::
vector
<
Function
*>&
getFunctions
()
const
{
return
functions
;
}
spv
::
Id
getTypeId
(
Id
resultId
)
const
{
return
idToInstruction
[
resultId
]
->
getTypeId
();
}
spv
::
Id
getTypeId
(
Id
resultId
)
const
{
return
idToInstruction
[
resultId
]
==
nullptr
?
NoType
:
idToInstruction
[
resultId
]
->
getTypeId
();
}
StorageClass
getStorageClass
(
Id
typeId
)
const
{
assert
(
idToInstruction
[
typeId
]
->
getOpCode
()
==
spv
::
OpTypePointer
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment