Commit Graph

491 Commits

Author SHA1 Message Date
Ehsan Nasiri
ff272a9820 Adding validation code for PtrAccessChain.
Validation for OpPtrAccessChain is similar to OpAccessChain with the
following difference: OpPtrAccessChain takes an extra argument (word 4)
which is the Element <id> argument.

Validation for OpInBoundsPtrAccessChain is also similar to OpPtrAccessChain.

Also added tests for all access chain instructions:
Modified the existing parameterized tests to accommodate OpPtrAccessChain and
OpInBoundsPtrAccessChain.

Also fixed a typo in previous commits.
2017-01-03 16:36:35 -05:00
Ehsan Nasiri
6993fc413d Validation code for control flow nesting depth.
According to Section 2.17 (Universal Limits) of the SPIR-V Spec, the
control flow nesting depth may not be larger than 1023.

This is checked only when we are required to have structured
control flow.  Otherwise it's not clear how to compute control
flow nesting depth.
2016-12-23 14:14:50 -05:00
David Neto
37422e9dba Support building under CYGWIN
- Parse CHANGES file with Universal Python line endings in case
  the source tree was checked out with Windows line endings.
- Use our own clone of strnlen_s which might not be available
  everywhere.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/508
2016-12-21 10:34:23 -05:00
David Neto
f8cc397573 Generate spvasm.vim
Generate a vim syntax file for SPIR-V assembly.
Copy the resulting spvasm.vim into your $HOME/.vim/syntax directory
to get syntax highlighting in Vim.

Also, suggest that the grammar file include information
about what opcodes can be used in OpSpecConstantOp.
2016-12-20 11:36:41 -05:00
David Neto
5a0b5ca4a7 Get vendor tool info from the SPIR-V registry file
Update old tests to use officially registered vendor names;
this affected "Codeplay".
2016-12-09 14:01:43 -05:00
Ehsan Nasiri
d004cd46db Adding validation for OpInBoundsAccessChain.
The validation for this instruction is similar to OpAccessChain.

Include a test for testing a struct with (valid) depth of 255.
2016-12-08 15:11:30 -05:00
Ehsan Nasiri
4fb79b54f2 Validation for struct nesting depth.
According to sectin 2.17 in SPIR-V Spec, the structure nesting depth may
not be larger than 255. This is interpreted as structures nested in
structures. The code does not look into arrays or follow pointers to see
if it reaches a structure downstream.

Use memoization to avoid exponential runtime.
2016-12-07 16:15:56 -05:00
David Neto
d5b0cd34c9 An OpVariable initializer can be a module-scope variable
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/482
2016-12-07 16:04:51 -05:00
Ehsan Nasiri
aadf696fce Fixing bug in OpAccessChain validation code.
The validation code for OpAccessChain was missing OpTypeRuntimeArray as
a possible type that can be indexed into.

This was caught by running the validator on VKCTS.

Also adding unit tests for it.
2016-12-06 09:55:39 -05:00
Ehsan Nasiri
bab1aad856 Adding validation code for OpAccessChain.
* Result Type must be an OpTypePointer. Its Type operand must be the
type reached by walking the Base’s type hierarchy down to the last
provided index in Indexes, and its Storage Class operand must be the
same as the Storage Class of Base.

* Base must be a pointer, pointing to the base of a composite object.

* Indexes walk the type hierarchy to the desired depth, potentially down
to scalar granularity. The first index in Indexes will select the
top-level member/element/component/element of the base composite. All
composite constituents use zero-based numbering, as described by their
OpType... instruction. The second index will apply similarly to that
result, and so on. Once any non-composite type is reached, there must
be no remaining (unused) indexes. Each of the Indexes must:
- be a scalar integer type,
- be an OpConstant when indexing into a structure.

* Check for the case where no indexes are passed to OpAccessChain.

Minor improvements based on code review.
2016-12-02 13:50:41 -05:00
Ehsan Nasiri
4b26d514ef Validate the number of global and local variables.
According to the Universal Limits section of the SPIR-V Spec (2.17), the
number of global variables may not exceed 65,535 and the number of local
variables may not exceed 524,287.

Also added unit tests for each one.
2016-12-01 16:04:13 -05:00
Ehsan Nasiri
490617133e Validate the number of arguments in OpTypeFunction
According to the SPIR-V spec (section 2.17: Universal Limits), the
OpTypeFunction instruction may not take more than 255 arguments for the
function. Also added unit tests for it.
2016-12-01 15:49:31 -05:00
Ehsan Nasiri
3c8bc80e3a Adding validation code for OpSwitch limits
The number of (literal, label) pairs passed to OpSwitch may not exceed
16,383. Added code to validate this and added unit tests for it.

Also fixed a typo in another validor error message.
2016-11-30 15:36:05 -05:00
Ehsan Nasiri
bef80716d7 Validation for number of Struct members.
The number of members in a struct may not exceed 16,383.
Also Adding unit tests for Struct size limit check.
2016-11-30 15:29:37 -05:00
Ehsan Nasiri
bd5b0bfca1 Checks that result IDs are within the ID bound specified in the SPIR-V header
This is described in Section 2.17 of the SPIR-V Spec.

* Updated existing unit test 'SemanticsIdIsAnIdNotALiteral' to pass by
manipulating the ID bound in its binary header.

* Fixed boundary check in the code.

* Added unit test to check the case that the largest ID is equal to the
ID bound.
2016-11-28 11:44:10 -05:00
Ehsan Nasiri
f72189c249 Validation for OpSampledImage instruction.
This change implements the validation for usages of OpSampledImage
instruction as described in the Data Rules section of the Universal
Validation Rules of the SPIR-V Spec.
2016-11-24 09:29:10 -05:00
Ehsan Nasiri
6fa6a3f647 Adding validation for OpSpecConstantComposite.
SpecConstantComposite may specialize to a vector, matrix, array, or
struct. In each case, the number of components and type of components
that are being specialized to must match the expected result type.

Removed use of macros in these tests.
Now using the spvValidateBase class. Using CompileSuccessfully(), and
ValidateInstructions() to compile to binary and run the validator. Also
using getDiagnosticString() to check the proper error message string.
All the heavy lifting is done in ValidateBase class.
2016-11-19 15:47:28 -05:00
Ehsan Nasiri
8c414eb579 Adding validation code for OpTypeStruct.
According to the Data Rules section of 2.16.1. Universal Validation
Rules of the SPIR-V Spec:

Forward reference operands in an OpTypeStruct
* must be later declared with OpTypePointer
* the type pointed to must be an OpTypeStruct
* had an earlier OpTypeForwardPointer forward reference to the same <id>
2016-11-16 16:41:56 -05:00
David Neto
c935253c91 Make friendly number-based names for OpConstant
For example:
  %int_42 = OpConstant %int 42
  %int_n42 = OpConstant %int -42
  %float_3_14 = OpConstant %float 3.14
2016-11-15 14:05:03 -05:00
David Neto
4f750c0dcc Extract EmitNumericLiteral from disassembler
Test with disassembly of numeric literals.
2016-11-15 14:05:03 -05:00
Ehsan Nasiri
d0620061c7 Adding validation code for more data rules.
These rules are under "Data Rules" in 2.16.1 (Universal Validation
Rules) part of the SPIR-V 1.1 Specification document:

* Scalar floating-point types can be parameterized only as 32 bit, plus
any additional sizes enabled by capabilities.

* Scalar integer types can be parameterized only as 32 bit, plus any
additional sizes enabled by capabilities.

* Vector types can only be parameterized with numerical types or the
OpTypeBool type.

* Matrix types can only be parameterized with floating-point types.

* Matrix types can only be parameterized as having only 2, 3, or 4
columns.

* Specialization constants (see Specialization) are limited to integers,
Booleans, floating-point numbers, and vectors of these.
2016-11-15 13:38:39 -05:00
Lei Zhang
38036a7203 Rename validation source files to comply with Google style guide. 2016-11-08 17:19:56 -08:00
Ehsan Nasiri
6c899a52f9 Adding validation for vector data rule.
Number of components in a vector can be 2 or 3 or 4. If Vector16
capability is used, 8 and 16 components are also allowed.
Also added unit tests for vector data rule.
2016-11-08 17:48:30 -05:00
David Neto
bf190ec839 Remove source/instruction.cpp
Avoids linker problems on Windows and OSX with duplicate object file
names.  Avoids collision with source/val/instruction.cpp

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/451
2016-11-03 11:40:52 -04:00
Jamie Madill
b371439d6f enum_set: Fix bool performance warning.
Implicit casts from int to bool cause a warning in visual studio.
2016-10-27 16:09:06 -04:00
Corentin Wallez
f92e87a8f8 Fix compilation errors when building inside Chromium
Example of an error:
    spirv-tools/source/validate_cfg.cpp:516:45: error: chosen constructor is
    explicit in copy-initialization:
      _.current_function().RegisterBlockEnd({}, opcode);
2016-10-04 17:47:19 -04:00
Lei Zhang
c1d5e660ee Add begin() and end() for TypeManager. 2016-09-30 16:56:42 -04:00
Lei Zhang
f9cb7c282c Avoid appending EOL in StringifyMessage().
EOL should be appended when outputing to streams by the tool.
2016-09-23 15:13:24 -04:00
Lei Zhang
dc6e4834d6 Clean up header dependency. 2016-09-22 18:15:23 -04:00
Umar Arshad
a6ef1ea29e Fix forward reference issues with forword pointer
* Allows OpTypeForwardPointer to reference IDs not yet declared in
  the module
* Allows OpTypeStruct to reference IDs not yet declared in
  the module

Possible Issue: OpTypeStruct should only allow forward references
if the ID is a pointer that is referenced by a forward pointer. Need
Type support in Validator which is currently a work in progress.
2016-09-22 16:54:02 -04:00
Lei Zhang
1ca817a38e Use nullptr as the default message consumer to ignore all messages.
There is no difference between the previous IgnoreMessage() function
and a null std::function, from functionality's perspective.
The user can set nullptr as the MessageConsumer, so need to guard
against nullptr before calling the consumer anyway. It's better
we use it internally so that it may expose problems by us instead
of the user.
2016-09-21 17:23:03 -04:00
Lei Zhang
6effeaa7f1 Change some asserts to normal errors in IrLoader. 2016-09-21 17:22:00 -04:00
Lei Zhang
3767e32b1f Add two more utility functions for sending errors to consumer. 2016-09-21 16:19:18 -04:00
Lei Zhang
74afb5d112 Change parameter name from file to source in Log() and Logf(). 2016-09-21 16:13:54 -04:00
Lei Zhang
5edf054926 Add more Assemble(), Disassemble() and Validate() overloads. 2016-09-21 14:42:04 -04:00
Lei Zhang
620f05e679 Publish the C++ interface. 2016-09-21 14:41:47 -04:00
Lei Zhang
92411caa3b Rename SpvTools to SpirvTools. 2016-09-21 14:28:33 -04:00
Lei Zhang
6849a3cefd Use C style names for MessageLevel. 2016-09-21 12:44:37 -04:00
Lei Zhang
80eb0793c9 Change to use enum instead of enum class for MessageLevel.
This allows us to create C interface with MessageLevel later.
2016-09-21 11:30:41 -04:00
Lei Zhang
f18e1f293b Add a C++ interface to the optimization functionalities. 2016-09-20 16:52:05 -04:00
Lei Zhang
1bc0b275dd Allow changing MessageConsumer in Pass & PassManager.
Default-constructed Pass/PassManager will have a MessageConsumer
which ignores all messages. SetMessageConsumer() should be called
to supply a meaningful MessageConsumer.
2016-09-20 16:48:00 -04:00
Lei Zhang
f8dbed0455 Change BuildModule() to accept pointer-size pair for binary. 2016-09-20 16:44:24 -04:00
Lei Zhang
2cbb2cce3e Change interface of Pass::Process() to return possible failures. 2016-09-20 16:40:17 -04:00
David Neto
12b5777912 Provide friendly names for shader ballot BuiltIns 2016-09-19 17:31:25 -04:00
Umar Arshad
bf467da9c9 Update validate interface to accept binary pointers 2016-09-19 16:43:28 -04:00
Lei Zhang
3590279a73 Set the default source name as "input". 2016-09-19 10:20:22 -04:00
David Neto
9382035a22 Add basic support for SPV_KHR_shader_ballot
Requires use of SPIRV-Headers that has support
for SPV_KHR_shader_ballot.

Adds assembler, disassembler, binary parser support.

Adds general support for allowing an operand to be
only enabled by a set of extensions.

TODO: Validator support for extension checking.
2016-09-16 16:38:36 -04:00
Lei Zhang
8654caa565 Prepare the C++ interface for publication.
* Use PIMPL idiom in the C++ interface.
* Clean up interface for assembling and disassembling.
* Add validation into C++ interface.
* Add more tests for the C++ interface.
2016-09-16 16:37:27 -04:00
Lei Zhang
b54686d017 Move functions for building modules outside of the C++ interface. 2016-09-16 14:02:47 -04:00
Lei Zhang
869440ebd4 Let SPIRV_ASSERT() exit the program if the assertion fails. 2016-09-16 13:14:57 -04:00
Lei Zhang
114af21994 Add MessageConsumer to PassManager, Pass, and analysis interfaces.
Also convert some uses of assert() in optimization code to use
SPIRV_ASSERT(), SPIRV_UNIMPLEMENTED(), or SPIRV_UNREACHABLE()
accordingly.
2016-09-16 13:14:57 -04:00
Lei Zhang
bfd7cd6d6e Add utility macros for logging messages.
Add the following macros for logging purpose:
* SPIRV_ASSERT
* SPIRV_DEBUG
* SPIRV_UNIMPLEMENTED
* SPIRV_UNREACHABLE

The last two is always turned on, while the first two can only
be turned on in debug build.
2016-09-16 09:56:34 -04:00
Lei Zhang
755f97f534 Add a callback mechanism for communicating messages to callers.
Every time an event happens in the library that the user should be
aware of, the callback will be invoked.

The existing diagnostic mechanism is hijacked internally by a
callback that creates an diagnostic object each time an event
happens.
2016-09-15 12:35:48 -04:00
David Neto
e0dd033414 Make friendly names for built-in variables.
Handles only OpDecorate

Does not handle:
- decorations on struct members
- decoration via OpGroupDecorate
2016-09-14 15:25:24 -04:00
David Neto
1f3fb506e8 Fix validator: OpUndef can be member of a constant composite
This was enabled in SPIR-V 1.0 Rev 7

Fixes: https://github.com/KhronosGroup/SPIRV-Tools/issues/414
2016-09-14 15:21:09 -04:00
David Neto
5c9080eea8 Fix validator SSA check: Phi can use its own value sometimes
Defer removal of a Phi's result id from the undefined-forward-reference
set until after you've scanned the arguments.  The reordering is only
significant for Phi.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/415
2016-09-14 15:15:28 -04:00
qining
66f5b4bfc5 Build "spec id->default val str" mapping from string
Add function `ParseDefaultValuesString()` to build the spec id->default
value string mapping required by `SetSpecConstantDefaultValuePass`.
2016-09-14 12:26:34 -04:00
qining
5ac63523d7 Guard against nullptr in number parsing utilities
ParseNumber(): Returns false if the given string is a nullptr.
ParseAndEncodeXXXX(): Returns kInvalidText and populate error message:
  "The given text is a nullptr", if the givne string is a nullptr.
2016-09-13 12:12:31 -04:00
qining
abf57933ea Set default values for spec const decorated by SpecId
The pass instance is constructed with a map from spec id (uint32_t) to
default values in string format. The default value strings will be
parsed to numbers according to the target spec constant type.

If the Spec Id decoration is found to be applied on multiple different
target ids, that decoration instruction (OpDecorate or OpGroupDecorate)
will be skipped. But other decoration instrucitons may still be
processed.
2016-09-12 23:21:42 -04:00
qining
049f80f3b9 Add IsSigned() to opt::Analysis::Integer. 2016-09-08 19:32:20 -04:00
qining
1773b95737 Pull out the number parsing logic
Pull out the number parsing logic from
AssemblyContext::binaryEncodeNumericLiteral() to utilities.

The new utility function: `ParseAndEncodeNumber()` now accepts:
  * number text to parse
  * number type
  * a emit function, which is a function which will be called with each
    parsed uint32 word.
  * a pointer to std::string to be overwritten with error messages.
    (pass nullptr if expect no error message)
and returns:
  * an enum result type to indicate the status

Type/Structs moved to utility:
  * template<typename T> class ClampToZeroIfUnsignedType

New type:
* enum EncodeNumberStatus: success or error code
* NumberType: hold the number type information for the number to be parsed.
 * several helper functions are also added for NumberType.

Functions moved to utility:
  * Helpers:
    * template<typename T> checkRangeAndIfHexThenSignExtend() -> CheckRangeAndIfHex....()
  * Interfaces:
    * template<typename T> parseNumber() -> ParseNumber()
    * binaryEncodeIntegerLiteral() -> ParseAndEncodeIntegerNumber()
    * binaryEncodeFloatingPointLiteral() -> ParseAndEncodeFloatingPointNumber()
    * binaryEncodeNumericLiteral() -> ParseAndEncodeNumber()

Tests added/moved to test/ParseNumber.cpp, including tests for:
* ParseNumber(): This is moved from TextToBinary.cpp to ParseNumber.cpp
* ParseAndEncodeIntegerNumber(): New added
* ParseAndEncodeFloatingPointNumber(): New added
* ParseAndEncodeNumber(): New added

Note that the error messages are kept almost the same as before, but
they may be inappropriate for an utility function. Those will be fixed
in another CL.
2016-09-08 18:42:54 -04:00
Lei Zhang
922246714e Kill the spvCheck macro which is just alias to if-statement. 2016-09-07 11:12:54 -04:00
David Neto
9fc8658ef3 Relicense SPIRV-Tools under Apache 2.0
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/383

Finalize v2016.4
2016-09-02 10:00:29 -04:00
David Neto
0e001b70e4 Fix Google copyright lines 2016-09-02 10:00:29 -04:00
Lei Zhang
5abf40816a Kill the spvCheckReturn macro. 2016-09-02 09:51:44 -04:00
Lei Zhang
75bf78c70b Kill diagnostic_helper & the wrapping DIAGNOSTIC macro. 2016-09-02 09:49:56 -04:00
Lei Zhang
2ad3b74fa3 Tests for preserving line debug insts even killing its affecting targets. 2016-09-01 11:51:09 -04:00
qining
eb60e2945a Unify constants pass
De-duplicate constants and unifies the uses of constants for a SPIR-V
module. If two constants are defined exactly the same, only one of them
will be kept and all the uses of the removed constant will be redirected
to the kept one.

This pass handles normal constants (defined with
OpConstant{|True|False|Composite}), some spec constants (those defined
with OpSpecConstant{Op|Composite}) and null constants (defined with
OpConstantNull).

There are several cases not handled by this pass:

  1) If there are decorations for the result id of a constant defining
  instruction, that instruction will not be processed. This means the
  instruction won't be used to replace other instructions and other
  instructions won't be used to replace it either.

  2) This pass does not unify null constants (defined with
  OpConstantNull instruction) with their equivalent zero-valued normal
  constants (defined with OpConstant{|False|Composite} with zero as the
  operand values or component values).
2016-09-01 11:46:05 -04:00
David Neto
909d7f9bf5 Refactor CapabilitySet into templated class EnumSet 2016-09-01 09:32:22 -04:00
qining
2ce67252c8 Add forwarding so that passes' ctor can have args.
Also removed the default argument value of `skip_nop` for function
`SinglePassRunAndCheck()` and `SinglePassRunAndDisassemble()`. This is
required to support variadic arguments.
2016-08-31 15:27:55 -04:00
David Neto
273920c554 Handle capabilities larger than value 63
Use libspirv::CapabilitySet instead of a 64-bit mask.

Remove dead function spvOpcodeRequiresCapability and its tests.

The JSON grammar parser is simplified since it just writes the
list of capabilities as a braced list, and takes advantage of
the CapabilitySet intializer-list constructor.
2016-08-30 15:41:39 -04:00
David Neto
47f2a1414b Add libspirv::CapabilitySet
It's optimized for the common case, where capabilities have value
at most 63.
2016-08-30 15:41:39 -04:00
qining
76982706f9 Get annotation instructions of a given id. 2016-08-30 15:08:24 -04:00
Lei Zhang
d9e63de117 Create a separate header and source file for each pass. 2016-08-29 15:46:09 -04:00
qining
380f36eae1 Fold spec constants to normal constants (values fixed)
For the spec constants defined by OpSpecConstantOp and
OpSpecContantComposite, if all of their operands are constants with
determined values (normal constants whose values are fixed), calculate
the correct values of the spec constants and re-define them as normal
constants.

In short, this pass replaces all the spec constants defined by
OpSpecContantOp and OpSpecConstantComposite with normal constants when
possible. So far not all valid operations of OpSpecConstantOp are
supported, we have several constriction here:

1) Only 32-bit integer and boolean (both scalar and vector) are
supported for any arithmetic operations. Integers in other width (like
64-bit) are not supported.
2) OpSConvert, OpFConvert, OpQuantizeToF16, and all the
operations under Kernel capability, are not supported.
3) OpCompositeInsert is not supported.

Note that this pass does not unify normal constants. This means it is
possible to have new generatd constants defining the same values.
2016-08-29 08:58:53 -04:00
David Neto
1d59aa0777 Pass manager recomputes Id bound automatically.
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/371
in the sense that the id bound is correct after all the passes
have been run.  But it might be inconsistent between passes.
2016-08-27 13:19:18 -04:00
Lei Zhang
b1b2cac2cf Create const overloads for begin() and end() in Instruction. 2016-08-26 21:58:49 -04:00
David Neto
d7b6362ed7 Add Module::ComputeIdBound
When IDs change, something should use this utility method
and Module::SetIdBound before writing out the binary.
2016-08-26 16:27:12 -04:00
qining
ec07a07724 Add a method in the types to check whether there is no decoration on a
type.
2016-08-26 12:09:21 -04:00
David Neto
cc60caba1d IrLoader gracefully handles incomplete blocks and functions
This lets us write smaller test cases with the IrLoader, avoiding
boilerplate for function begin/end, and basic block begin/end.

Also ForEachInst is more forgiving of cases where a basic block
doesn't have a label, and when a function doesn't have a defining
or end instruction.
2016-08-26 10:15:15 -04:00
David Neto
53013cc816 Add Instruction begin and end mutable iterators
Refactored the instuction test.
2016-08-25 17:48:58 -04:00
David Neto
2607bbf30b Add Instruction cbegin and cend to access operands 2016-08-25 15:24:32 -04:00
David Neto
97fc6aa3b8 ForEachInst optionally runs on attached debug line insts
Also:
- Add const forms of ForEachInst
- Rewrite Module::ToBinary in terms of ForEachInst
- Add Instruction::ToBinaryWithoutAttachedDebugInsts
- Delete the ToBinary method on Function, BasicBlock, and Instruction
  since it can now be implemented with ForEachInst in a less confusing
  way, e.g. without recursion.
- Preserve debug line instructions on OpFunctionEnd (and store that
  instruction as a unique-pointer, for regularity).
2016-08-25 11:43:22 -04:00
David Neto
97d06a36b0 Mere mention of PointSize BuiltIn does not require Shader capability
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/365 which
was reopened for this.
2016-08-24 10:04:17 -04:00
Lei Zhang
f51d82338e Add a home brewed make_unique to ease creating unique_ptrs. 2016-08-24 09:41:55 -04:00
Lei Zhang
6f13c73229 Remove some unused macros and functions. 2016-08-24 09:34:06 -04:00
David Neto
358cb2940a Relax ClipDistance, CullDistance capability check in all environments
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/365
2016-08-23 18:41:44 -04:00
David Neto
ccabcc4673 Add opt::ir::Module::SetIdBound 2016-08-23 15:20:34 -04:00
qining
7e775aa99e Get the number of elements for Vector and Matrix type 2016-08-23 11:34:24 -04:00
qining
b891845b53 Refine the DefUseManager
* Fix the behavior when analyzing an individual instruction:
  * exisiting instruction:
      Clear the original records and re-analyze it as a new instruction.
  * new instruction with exisiting result id:
      Clear the original records of the exisiting result id. This means
      the records of the analyzed result-id-defining instruction will be
      overwritten by the record of the new instruction with the same
      result id.
  * new instruction with new result id or without result id:
      Just update the internal records to incorperate the new
      instruction.
* Add tests for analyzing individual instruction w/o an exisiting module.
* Refactor ClearInst() implementation
* Remove ClearDef() function.
* Fixed a bug in DefUseManager::ReplaceAllUsesWith() that OpName
  instruction may trigger the assertion incorrectly.
* update the blurbs for EraseUseRecordsOfOperandIds()
2016-08-17 23:13:01 -04:00
qining
6c5bdc9a39 Get the width from integer and float type 2016-08-17 20:33:56 -04:00
qining
e8b7c7b210 Replace the SetOperand() with SetInOperand() and SetResultType() 2016-08-16 15:05:07 -04:00
Lei Zhang
b65124f097 Make clear that we are using ptrdiff_t as the iterator difference type.
And ptrdiff_t is a implementation defined signed type. Comparing it
with unsigned number literal causes compiler warnings.
2016-08-16 11:21:08 -04:00
Lei Zhang
9747d33d08 Derive iterator from std::iterator to reap standarad algorithms.
By deriving from std::iterator, iterator_traits will be properly
set up for our custom iterator type, thus we can use algorithms
from STL with our custom iterators.
2016-08-15 16:29:56 -04:00
Lei Zhang
1eec0ed4b9 Make analyses RAII-like and turn disable copy/move constructors. 2016-08-15 13:41:47 -04:00
Lei Zhang
097ff25ea7 Allow OpUndef appearing in the type and global variable section.
Also clean up API functions for adding instructions into the
type and global values section.
2016-08-15 10:44:14 -04:00
qining
c814911904 Add another construtor for opt::ir::Instruction 2016-08-13 11:17:11 -04:00
qining
d065593404 Add iterator getter interface for types_values_ 2016-08-12 15:10:51 -04:00
Umar Arshad
b01755a5e2 OpUndef can appear in type declaration section 2016-08-12 14:28:17 -04:00
Lei Zhang
94912ad1ba Turn off modifying methods for const iterators. 2016-08-12 14:05:41 -04:00