Skip to content

Commit 7b5e9d8

Browse files
author
joaosaffran
committed
addressing comments and clean up
1 parent 2894f96 commit 7b5e9d8

File tree

9 files changed

+27
-30
lines changed

9 files changed

+27
-30
lines changed

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "llvm/Support/SwapByteOrder.h"
1818
#include "llvm/TargetParser/Triple.h"
1919

20-
#include <cstdint>
2120
#include <stdint.h>
2221

2322
namespace llvm {

llvm/include/llvm/MC/DXContainerRootSignature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/BinaryFormat/DXContainer.h"
10-
#include <cstddef>
1110
#include <cstdint>
11+
#include <limits>
1212

1313
namespace llvm {
1414

llvm/include/llvm/Object/DXContainer.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ template <typename T> struct ViewArray {
116116
};
117117

118118
namespace DirectX {
119+
119120
struct RootParameter {
120121
dxbc::RootParameterHeader Header;
121122
union {
@@ -144,9 +145,9 @@ class RootSignature {
144145
uint32_t getRootParametersOffset() const { return RootParametersOffset; }
145146
uint32_t getNumStaticSamplers() const { return NumStaticSamplers; }
146147
uint32_t getStaticSamplersOffset() const { return StaticSamplersOffset; }
147-
ParamsIter beginParams() { return Parameters.begin(); }
148-
149-
ParamsIter endParams() { return Parameters.end(); }
148+
llvm::iterator_range<const RootParameter *> getParameters() const {
149+
return llvm::make_range(Parameters.begin(), Parameters.end());
150+
}
150151
uint32_t getFlags() const { return Flags; }
151152
};
152153

llvm/include/llvm/ObjectYAML/DXContainerYAML.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "llvm/BinaryFormat/DXContainer.h"
2020
#include "llvm/Object/DXContainer.h"
2121
#include "llvm/ObjectYAML/YAML.h"
22-
#include "llvm/Support/ErrorHandling.h"
2322
#include "llvm/Support/YAMLTraits.h"
2423
#include <array>
2524
#include <cstdint>
@@ -88,16 +87,17 @@ struct RootParameterYamlDesc {
8887
uint32_t Offset;
8988

9089
RootParameterYamlDesc() = default;
91-
RootParameterYamlDesc(object::DirectX::RootParameter *Parameter) {
92-
Type = Parameter->Header.ParameterType;
93-
Visibility = Parameter->Header.ShaderVisibility;
94-
Offset = Parameter->Header.ParameterOffset;
95-
switch (Parameter->Header.ParameterType) {
90+
RootParameterYamlDesc(const object::DirectX::RootParameter &Parameter) {
91+
92+
Type = Parameter.Header.ParameterType;
93+
Visibility = Parameter.Header.ShaderVisibility;
94+
Offset = Parameter.Header.ParameterOffset;
95+
switch (Parameter.Header.ParameterType) {
9696

9797
case dxbc::RootParameterType::Constants32Bit: {
98-
Constants.Num32BitValues = Parameter->Constants.Num32BitValues;
99-
Constants.RegisterSpace = Parameter->Constants.RegisterSpace;
100-
Constants.ShaderRegister = Parameter->Constants.ShaderRegister;
98+
Constants.Num32BitValues = Parameter.Constants.Num32BitValues;
99+
Constants.RegisterSpace = Parameter.Constants.RegisterSpace;
100+
Constants.ShaderRegister = Parameter.Constants.ShaderRegister;
101101
} break;
102102
case dxbc::RootParameterType::Empty:
103103
llvm_unreachable("Invalid Root Parameter Type. It should be verified "
@@ -112,7 +112,7 @@ struct RootParameterYamlDesc {
112112

113113
struct RootSignatureYamlDesc {
114114
RootSignatureYamlDesc() = default;
115-
RootSignatureYamlDesc(object::DirectX::RootSignature Data);
115+
RootSignatureYamlDesc(const object::DirectX::RootSignature &Data);
116116

117117
uint32_t Version;
118118
uint32_t NumStaticSamplers;

llvm/lib/MC/DXContainerRootSignature.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88

99
#include "llvm/MC/DXContainerRootSignature.h"
1010
#include "llvm/ADT/SmallString.h"
11-
#include "llvm/ADT/SmallVector.h"
1211
#include "llvm/BinaryFormat/DXContainer.h"
1312
#include "llvm/Support/EndianStream.h"
14-
#include <cstdint>
1513

1614
using namespace llvm;
1715
using namespace llvm::mcdxbc;

llvm/lib/ObjectYAML/DXContainerEmitter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "llvm/ObjectYAML/yaml2obj.h"
1919
#include "llvm/Support/Errc.h"
2020
#include "llvm/Support/Error.h"
21-
#include "llvm/Support/ErrorHandling.h"
2221
#include "llvm/Support/raw_ostream.h"
2322

2423
using namespace llvm;

llvm/lib/ObjectYAML/DXContainerYAML.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "llvm/ObjectYAML/DXContainerYAML.h"
1515
#include "llvm/ADT/ScopeExit.h"
1616
#include "llvm/BinaryFormat/DXContainer.h"
17-
#include "llvm/Object/DXContainer.h"
1817
#include "llvm/Support/ScopedPrinter.h"
1918

2019
namespace llvm {
@@ -31,12 +30,12 @@ DXContainerYAML::ShaderFeatureFlags::ShaderFeatureFlags(uint64_t FlagData) {
3130
}
3231

3332
DXContainerYAML::RootSignatureYamlDesc::RootSignatureYamlDesc(
34-
object::DirectX::RootSignature Data)
33+
const object::DirectX::RootSignature &Data)
3534
: Version(Data.getVersion()),
3635
NumStaticSamplers(Data.getNumStaticSamplers()),
3736
StaticSamplersOffset(Data.getStaticSamplersOffset()) {
3837
uint32_t Flags = Data.getFlags();
39-
for (auto *P = Data.beginParams(); P != Data.endParams(); ++P) {
38+
for (auto const &P : Data.getParameters()) {
4039

4140
Parameters.push_back(RootParameterYamlDesc(P));
4241
}

llvm/unittests/Object/DXContainerTest.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -912,18 +912,19 @@ TEST(RootSignature, ParseRootConstant) {
912912
auto RS = C.getRootSignature();
913913
ASSERT_TRUE(RS.has_value());
914914
ASSERT_EQ(RS->getVersion(), 2u);
915-
ASSERT_EQ(RS->getNumParameters(), 1);
915+
ASSERT_EQ(RS->getNumParameters(), 1u);
916916
ASSERT_EQ(RS->getRootParametersOffset(), 24u);
917917
ASSERT_EQ(RS->getNumStaticSamplers(), 0u);
918918
ASSERT_EQ(RS->getStaticSamplersOffset(), 44u);
919919
ASSERT_EQ(RS->getFlags(), 17u);
920920

921-
object::DirectX::RootParameter *RootParam = RS->beginParams();
922-
ASSERT_EQ((uint32_t)RootParam->Header.ParameterType, 1u);
923-
ASSERT_EQ((uint32_t)RootParam->Header.ShaderVisibility, 2u);
924-
ASSERT_EQ(RootParam->Constants.ShaderRegister, 15u);
925-
ASSERT_EQ(RootParam->Constants.RegisterSpace, 14u);
926-
ASSERT_EQ(RootParam->Constants.Num32BitValues, 16u);
921+
for (auto const &RootParam : RS->getParameters()) {
922+
ASSERT_EQ((uint32_t)RootParam.Header.ParameterType, 1u);
923+
ASSERT_EQ((uint32_t)RootParam.Header.ShaderVisibility, 2u);
924+
ASSERT_EQ(RootParam.Constants.ShaderRegister, 15u);
925+
ASSERT_EQ(RootParam.Constants.RegisterSpace, 14u);
926+
ASSERT_EQ(RootParam.Constants.Num32BitValues, 16u);
927+
}
927928
}
928929
{
929930
// ParameterType has been set to an invalid value

llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ TEST(RootSignature, ParseRootFlags) {
134134
)"));
135135

136136
uint8_t Buffer[] = {
137-
0x44, 0x58, 0x42, 0x43, 0x32, 0x9a, 0x53, 0xd8, 0xec, 0xbe, 0x35, 0x6f,
138-
0x05, 0x39, 0xe1, 0xfe, 0x31, 0x20, 0xf0, 0xc1, 0x01, 0x00, 0x00, 0x00,
137+
0x44, 0x58, 0x42, 0x43, 0x32, 0x9A, 0x53, 0xD8, 0xEC, 0xBE, 0x35, 0x6F,
138+
0x05, 0x39, 0xE1, 0xFE, 0x31, 0x20, 0xF0, 0xC1, 0x01, 0x00, 0x00, 0x00,
139139
0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
140140
0x52, 0x54, 0x53, 0x30, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
141141
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0 commit comments

Comments
 (0)