Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
617 changes: 617 additions & 0 deletions enzyme/Enzyme/ActiveVariable.cpp

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions enzyme/Enzyme/ActiveVariable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* ActiveVariable.h - Active Varaible Detection Utilities
*
* Copyright (C) 2019 William S. Moses (enzyme@wsmoses.com) - All Rights Reserved
*
* For commercial use of this code please contact the author(s) above.
*
* For research use of the code please use the following citation.
*
* \misc{mosesenzyme,
author = {William S. Moses, Tim Kaler},
title = {Enzyme: LLVM Automatic Differentiation},
year = {2019},
howpublished = {\url{https://github.com/wsmoses/Enzyme/}},
note = {commit xxxxxxx}
*/
#ifndef ENZYME_ACTIVE_VAR_H
#define ENZYME_ACTIVE_VAR_H 1

#include <cstdint>

#include <llvm/Config/llvm-config.h>

#include "llvm/IR/Constants.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"

#include "llvm/Support/CommandLine.h"

extern llvm::cl::opt<bool> printconst;

bool isIntASecretFloat(llvm::Value* val);

//! return the secret float type if found, otherwise nullptr
llvm::Type* isIntPointerASecretFloat(llvm::Value* val);

bool isconstantValueM(llvm::Value* val, llvm::SmallPtrSetImpl<llvm::Value*> &constants, llvm::SmallPtrSetImpl<llvm::Value*> &nonconstant, const llvm::SmallPtrSetImpl<llvm::Value*> &retvals, const llvm::SmallPtrSetImpl<llvm::Instruction*> &originalInstructions, uint8_t directions=3);

// TODO separate if the instruction is constant (i.e. could change things)
// from if the value is constant (the value is something that could be differentiated)
bool isconstantM(llvm::Instruction* inst, llvm::SmallPtrSetImpl<llvm::Value*> &constants, llvm::SmallPtrSetImpl<llvm::Value*> &nonconstant, const llvm::SmallPtrSetImpl<llvm::Value*> &retvals, const llvm::SmallPtrSetImpl<llvm::Instruction*> &originalInstructions, uint8_t directions=3);

#endif
36 changes: 19 additions & 17 deletions enzyme/Enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@
# set(LLVM_LINK_COMPONENTS Core Support)
#endif()

file(GLOB ENZYME_SRC
"*.cpp"
)

list(APPEND ENZYME_SRC SCEV/ScalarEvolutionExpander.cpp)

if (${LLVM_VERSION_MAJOR} LESS 8)
add_llvm_loadable_module( LLVMEnzyme-${LLVM_VERSION_MAJOR}
Enzyme.cpp
Utils.cpp
SCEV/ScalarEvolutionExpander.cpp
DEPENDS
intrinsics_gen
PLUGIN_TOOL
opt
)
${ENZYME_SRC}
DEPENDS
intrinsics_gen
PLUGIN_TOOL
opt
)
else()
add_llvm_library( LLVMEnzyme-${LLVM_VERSION_MAJOR}
Enzyme.cpp
Utils.cpp
SCEV/ScalarEvolutionExpander.cpp
MODULE
DEPENDS
intrinsics_gen
PLUGIN_TOOL
opt
)
${ENZYME_SRC}
MODULE
DEPENDS
intrinsics_gen
PLUGIN_TOOL
opt
)

endif()
Loading