// Copyright 2020 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
//    list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
//    contributors may be used to endorse or promote products derived from
//    this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef SRC_TINT_LANG_WGSL_SEM_BUILTIN_FN_H_
#define SRC_TINT_LANG_WGSL_SEM_BUILTIN_FN_H_

#include <string>
#include <vector>

#include "src/tint/lang/wgsl/builtin_fn.h"
#include "src/tint/lang/wgsl/extension.h"
#include "src/tint/lang/wgsl/features/language_feature.h"
#include "src/tint/lang/wgsl/sem/call_target.h"
#include "src/tint/lang/wgsl/sem/pipeline_stage_set.h"
#include "src/tint/utils/math/hash.h"

// Forward declarations
namespace tint::core::intrinsic {
struct OverloadInfo;
}

namespace tint::sem {

/// BuiltinFn holds the semantic information for a builtin function.
class BuiltinFn final : public Castable<BuiltinFn, CallTarget> {
  public:
    /// Constructor
    /// @param type the builtin type
    /// @param return_type the return type for the builtin call
    /// @param parameters the parameters for the builtin overload
    /// @param eval_stage the earliest evaluation stage for a call to the builtin
    /// @param supported_stages the pipeline stages that this builtin can be used in
    /// @param overload the builtin table overload
    BuiltinFn(wgsl::BuiltinFn type,
              const core::type::Type* return_type,
              VectorRef<Parameter*> parameters,
              core::EvaluationStage eval_stage,
              PipelineStageSet supported_stages,
              const core::intrinsic::OverloadInfo& overload);

    /// Destructor
    ~BuiltinFn() override;

    /// @return the type of the builtin
    wgsl::BuiltinFn Fn() const { return fn_; }

    /// @return the pipeline stages that this builtin can be used in
    PipelineStageSet SupportedStages() const { return supported_stages_; }

    /// @return true if the builtin overload is considered deprecated
    bool IsDeprecated() const;

    /// @returns the name of the builtin function type. The spelling, including
    /// case, matches the name in the WGSL spec.
    const char* str() const;

    /// @returns true if builtin is a coarse derivative builtin
    bool IsCoarseDerivative() const;

    /// @returns true if builtin is a fine a derivative builtin
    bool IsFineDerivative() const;

    /// @returns true if builtin is a derivative builtin
    bool IsDerivative() const;

    /// @returns true if builtin is a texture operation builtin
    bool IsTexture() const;

    /// @returns true if builtin is a image query builtin
    bool IsImageQuery() const;

    /// @returns true if builtin is a data packing builtin
    bool IsDataPacking() const;

    /// @returns true if builtin is a data unpacking builtin
    bool IsDataUnpacking() const;

    /// @returns true if builtin is a barrier builtin
    bool IsBarrier() const;

    /// @returns true if builtin is a atomic builtin
    bool IsAtomic() const;

    /// @returns true if builtin is a builtin defined in the language extension
    /// `packed_4x8_integer_dot_product`.
    bool IsPacked4x8IntegerDotProductBuiltin() const;

    /// @returns true if builtin is a subgroup builtin (defined in the extension
    /// chromium_experimental_subgroups)
    bool IsSubgroup() const;

    /// @returns true if builtin is a quadSwap builtin
    bool IsQuadSwap() const;

    /// @returns true if intrinsic may have side-effects (i.e. writes to at least
    /// one of its inputs)
    bool HasSideEffects() const;

    /// @returns the required language feature of this builtin function. Returns
    /// wgsl::LanguageFeature::kUndefined if no language feature is required.
    wgsl::LanguageFeature RequiredLanguageFeature() const;

    /// @returns the builtin table overload info
    const core::intrinsic::OverloadInfo& Overload() const { return overload_; }

    /// @return the hash code for this object
    tint::HashCode HashCode() const {
        return Hash(Fn(), SupportedStages(), ReturnType(), Parameters(), IsDeprecated());
    }

  private:
    const wgsl::BuiltinFn fn_;
    const PipelineStageSet supported_stages_;
    const core::intrinsic::OverloadInfo& overload_;
};

/// Constant value used by the degrees() builtin
static constexpr double kRadToDeg = 57.295779513082322865;

/// Constant value used by the radians() builtin
static constexpr double kDegToRad = 0.017453292519943295474;

}  // namespace tint::sem

#endif  // SRC_TINT_LANG_WGSL_SEM_BUILTIN_FN_H_
