<commit_before>#include <iostream>
#include <sstream>

#include "LLVM_Headers.h"
#include "CodeGen_Hexagon.h"
#include "IROperator.h"
#include "IRMatch.h"
#include "IREquality.h"
#include "Target.h"
#include "Debug.h"
#include "Util.h"
#include "Simplify.h"
#include "IRPrinter.h"
#include "EliminateBoolVectors.h"
#include "HexagonOptimize.h"

#define IPICK(i64) (B128 ? i64##_128B : i64)

namespace Halide {
namespace Internal {

using std::vector;
using std::string;
using std::ostringstream;
using std::pair;
using std::make_pair;

using namespace llvm;

CodeGen_Hexagon::CodeGen_Hexagon(Target t) : CodeGen_Posix(t) {}

std::unique_ptr<llvm::Module> CodeGen_Hexagon::compile(const Module &module) {
    auto llvm_module = CodeGen_Posix::compile(module);
    static bool options_processed = false;

    // TODO: This should be set on the module itself, or some other
    // safer way to pass this through to the target specific lowering
    // passes. We set the option here (after the base class'
    // implementaiton of compile) because it is the last
    // Hexagon-specific code to run prior to invoking the target
    // specific lowering in LLVM, minimizing the chances of the wrong
    // flag being set for the wrong module.
    if (!options_processed) {
      cl::ParseEnvironmentOptions("halide-hvx-be", "HALIDE_LLVM_ARGS",
                                  "Halide HVX internal compiler\n");
      // We need to EnableQuIC for LLVM and Halide (Unrolling).
      char *s = strdup("HALIDE_LLVM_QUIC=-hexagon-small-data-threshold=0");
      ::putenv(s);
      cl::ParseEnvironmentOptions("halide-hvx-be", "HALIDE_LLVM_QUIC",
                                  "Halide HVX quic option\n");
    }
    options_processed = true;

    string hvx_setting = "+hvx,-hvx-double";
    if (module.target().has_feature(Halide::Target::HVX_128)) {
        hvx_setting = "+hvx,+hvx-double";
        if (module.target().has_feature(Halide::Target::HVX_64))
                internal_error << "Both HVX_64 and HVX_128 set at same time\n";
    }
    for (llvm::Module::iterator iter = llvm_module->begin();
         iter != llvm_module->end(); iter++) {
        llvm::Function *f = (llvm::Function *)(iter);
        if (!f->isDeclaration()) {
            f->addFnAttr("target-features", hvx_setting);
        }<commit_msg>use llvm::Function &fn : llvm_module->functions()<commit_after>#include <iostream>
#include <sstream>

#include "LLVM_Headers.h"
#include "CodeGen_Hexagon.h"
#include "IROperator.h"
#include "IRMatch.h"
#include "IREquality.h"
#include "Target.h"
#include "Debug.h"
#include "Util.h"
#include "Simplify.h"
#include "IRPrinter.h"
#include "EliminateBoolVectors.h"
#include "HexagonOptimize.h"

#define IPICK(i64) (B128 ? i64##_128B : i64)

namespace Halide {
namespace Internal {

using std::vector;
using std::string;
using std::ostringstream;
using std::pair;
using std::make_pair;

using namespace llvm;

CodeGen_Hexagon::CodeGen_Hexagon(Target t) : CodeGen_Posix(t) {}

std::unique_ptr<llvm::Module> CodeGen_Hexagon::compile(const Module &module) {
    auto llvm_module = CodeGen_Posix::compile(module);
    static bool options_processed = false;

    // TODO: This should be set on the module itself, or some other
    // safer way to pass this through to the target specific lowering
    // passes. We set the option here (after the base class'
    // implementaiton of compile) because it is the last
    // Hexagon-specific code to run prior to invoking the target
    // specific lowering in LLVM, minimizing the chances of the wrong
    // flag being set for the wrong module.
    if (!options_processed) {
      cl::ParseEnvironmentOptions("halide-hvx-be", "HALIDE_LLVM_ARGS",
                                  "Halide HVX internal compiler\n");
      // We need to EnableQuIC for LLVM and Halide (Unrolling).
      char *s = strdup("HALIDE_LLVM_QUIC=-hexagon-small-data-threshold=0");
      ::putenv(s);
      cl::ParseEnvironmentOptions("halide-hvx-be", "HALIDE_LLVM_QUIC",
                                  "Halide HVX quic option\n");
    }
    options_processed = true;

    string hvx_setting = "+hvx,-hvx-double";
    if (module.target().has_feature(Halide::Target::HVX_128)) {
        hvx_setting = "+hvx,+hvx-double";
        if (module.target().has_feature(Halide::Target::HVX_64))
                internal_error << "Both HVX_64 and HVX_128 set at same time\n";
    }
    for (llvm::Function &fn : llvm_module->functions()) {
        if (fn.isDeclaration()) {
            fn.addFnAttr("target-features", hvx_setting);
        }
{'fraction_non_alphanumeric': 0.12667104974797283, 'fraction_numerical': 0.010081087004163927, 'mean_word_length': 3.418199419167473, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7185680', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1453, 'n_words': 382}