intrinsic_table.def: Support [[deprecated]] on fn
And produce a warning if these are used. Hard to test, as we don't want to introduce fake functions in our definition file. Also add missing cast in EnumMatcher. Bug: tint:806 Change-Id: I21f189e4befe419f6d5544acfc52387d9a5da782 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54001 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
06e2e5c2f7
commit
3e59eb0e5c
|
@ -663,10 +663,12 @@ struct OverloadInfo {
|
|||
ParameterInfo const* const parameters;
|
||||
/// Pointer to a list of matcher indices that index on Matchers::type and
|
||||
/// Matchers::number, used to build the return type. If the function has no
|
||||
/// return type then this is null.
|
||||
/// return type then this is null
|
||||
MatcherIndex const* const return_matcher_indices;
|
||||
/// The pipeline stages that this overload can be used in.
|
||||
/// The pipeline stages that this overload can be used in
|
||||
PipelineStageSet supported_stages;
|
||||
/// True if the overload is marked as deprecated
|
||||
bool is_deprecated;
|
||||
};
|
||||
|
||||
/// IntrinsicInfo describes an intrinsic function
|
||||
|
@ -878,7 +880,7 @@ const sem::Intrinsic* Impl::Match(sem::IntrinsicType intrinsic_type,
|
|||
|
||||
return builder.create<sem::Intrinsic>(
|
||||
intrinsic_type, const_cast<sem::Type*>(return_type),
|
||||
std::move(parameters), overload.supported_stages);
|
||||
std::move(parameters), overload.supported_stages, overload.is_deprecated);
|
||||
}
|
||||
|
||||
MatchState Impl::Match(ClosedState& closed,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -101,6 +101,7 @@ constexpr OverloadInfo kOverloads[] = {
|
|||
{{- range $i, $u := $o.CanBeUsedInStage.List -}}
|
||||
{{- if $i -}}, {{end}}PipelineStage::k{{Title $u}}
|
||||
{{- end }}),
|
||||
/* is_deprecated */ {{$o.IsDeprecated}},
|
||||
},
|
||||
{{- end }}
|
||||
};
|
||||
|
@ -247,7 +248,7 @@ class {{$class}} : public NumberMatcher {
|
|||
{{- $entry := printf "k%v" (PascalCase $option.Name) -}}
|
||||
Number {{$class}}::Match(MatchState&, Number number) const {
|
||||
if (number.IsAny() || number.Value() == static_cast<uint32_t>({{$enum}}::{{$entry}})) {
|
||||
return Number({{$enum}}::{{$entry}});
|
||||
return Number(static_cast<uint32_t>({{$enum}}::{{$entry}}));
|
||||
}
|
||||
return Number::invalid;
|
||||
}
|
||||
|
|
|
@ -1723,6 +1723,10 @@ bool Resolver::IntrinsicCall(ast::CallExpression* call,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (result->IsDeprecated()) {
|
||||
diagnostics_.add_warning("use of deprecated intrinsic", call->source());
|
||||
}
|
||||
|
||||
builder_->Sem().Add(
|
||||
call, builder_->create<sem::Call>(call, result, current_statement_));
|
||||
SetType(call, result->ReturnType());
|
||||
|
|
|
@ -90,10 +90,12 @@ bool IsBarrierIntrinsic(IntrinsicType i) {
|
|||
Intrinsic::Intrinsic(IntrinsicType type,
|
||||
sem::Type* return_type,
|
||||
const ParameterList& parameters,
|
||||
PipelineStageSet supported_stages)
|
||||
PipelineStageSet supported_stages,
|
||||
bool is_deprecated)
|
||||
: Base(return_type, parameters),
|
||||
type_(type),
|
||||
supported_stages_(supported_stages) {}
|
||||
supported_stages_(supported_stages),
|
||||
is_deprecated_(is_deprecated) {}
|
||||
|
||||
Intrinsic::~Intrinsic() = default;
|
||||
|
||||
|
|
|
@ -78,10 +78,13 @@ class Intrinsic : public Castable<Intrinsic, CallTarget> {
|
|||
/// @param parameters the parameters for the intrinsic overload
|
||||
/// @param supported_stages the pipeline stages that this intrinsic can be
|
||||
/// used in
|
||||
/// @param is_deprecated true if the particular overload is considered
|
||||
/// deprecated
|
||||
Intrinsic(IntrinsicType type,
|
||||
sem::Type* return_type,
|
||||
const ParameterList& parameters,
|
||||
PipelineStageSet supported_stages);
|
||||
PipelineStageSet supported_stages,
|
||||
bool is_deprecated);
|
||||
|
||||
/// Destructor
|
||||
~Intrinsic() override;
|
||||
|
@ -92,6 +95,9 @@ class Intrinsic : public Castable<Intrinsic, CallTarget> {
|
|||
/// @return the pipeline stages that this intrinsic can be used in
|
||||
PipelineStageSet SupportedStages() const { return supported_stages_; }
|
||||
|
||||
/// @return true if the intrinsic overload is considered deprecated
|
||||
bool IsDeprecated() const { return is_deprecated_; }
|
||||
|
||||
/// @returns the name of the intrinsic function type. The spelling, including
|
||||
/// case, matches the name in the WGSL spec.
|
||||
const char* str() const;
|
||||
|
@ -126,6 +132,7 @@ class Intrinsic : public Castable<Intrinsic, CallTarget> {
|
|||
private:
|
||||
IntrinsicType const type_;
|
||||
PipelineStageSet const supported_stages_;
|
||||
bool const is_deprecated_;
|
||||
};
|
||||
|
||||
/// Emits the name of the intrinsic function type. The spelling, including case,
|
||||
|
|
|
@ -98,6 +98,8 @@ type Overload struct {
|
|||
ReturnMatcherIndicesOffset *int
|
||||
// StageUses describes the stages an overload can be used in
|
||||
CanBeUsedInStage sem.StageUses
|
||||
// True if the overload is marked as deprecated
|
||||
IsDeprecated bool
|
||||
}
|
||||
|
||||
// Function is used to create the C++ IntrinsicInfo structure
|
||||
|
@ -196,6 +198,7 @@ func (b *intrinsicTableBuilder) buildOverload(o *sem.Overload) (Overload, error)
|
|||
ParametersOffset: b.lut.parameters.Add(ob.parameters),
|
||||
ReturnMatcherIndicesOffset: ob.returnTypeMatcherIndicesOffset,
|
||||
CanBeUsedInStage: o.CanBeUsedInStage,
|
||||
IsDeprecated: o.IsDeprecated,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -275,6 +275,12 @@ func (r *resolver) function(a ast.FunctionDecl) error {
|
|||
Compute: true,
|
||||
}
|
||||
}
|
||||
if deprecated := a.Decorations.Take("deprecated"); deprecated != nil {
|
||||
overload.IsDeprecated = true
|
||||
if len(deprecated.Values) != 0 {
|
||||
return fmt.Errorf("%v unexpected value for deprecated decoration", deprecated.Source)
|
||||
}
|
||||
}
|
||||
if len(a.Decorations) != 0 {
|
||||
return fmt.Errorf("%v unknown decoration", a.Decorations[0].Source)
|
||||
}
|
||||
|
|
|
@ -137,6 +137,7 @@ type Overload struct {
|
|||
ReturnType *FullyQualifiedName
|
||||
Parameters []Parameter
|
||||
CanBeUsedInStage StageUses
|
||||
IsDeprecated bool // True if this overload is deprecated
|
||||
}
|
||||
|
||||
// StageUses describes the stages an overload can be used in
|
||||
|
|
Loading…
Reference in New Issue