mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-13 21:05:16 +00:00
e8be6c6391
replacement of multiple values. This is slightly more efficient than doing multiple ReplaceAllUsesOfValueWith calls, and theoretically could be optimized even further. However, an important property of this new function is that it handles the case where the source value set and destination value set overlap. This makes it feasible for isel to use SelectNodeTo in many very common cases, which is advantageous because SelectNodeTo avoids a temporary node and it doesn't require CSEMap updates for users of values that don't change position. Revamp MorphNodeTo, which is what does all the work of SelectNodeTo, to handle operand lists more efficiently, and to correctly handle a number of corner cases to which its new wider use exposes it. This commit also includes a change to the encoding of post-isel opcodes in SDNodes; now instead of being sandwiched between the target-independent pre-isel opcodes and the target-dependent pre-isel opcodes, post-isel opcodes are now represented as negative values. This makes it possible to test if an opcode is pre-isel or post-isel without having to know the size of the current target's post-isel instruction set. These changes speed up llc overall by 3% and reduce memory usage by 10% on the InstructionCombining.cpp testcase with -fast and -regalloc=local. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53728 91177308-0d34-0410-b5e6-96231b3b80d8
74 lines
1.9 KiB
C++
74 lines
1.9 KiB
C++
//===--- Allocator.h - Simple memory allocation abstraction -----*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines the MallocAllocator and BumpPtrAllocator interfaces.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_SUPPORT_ALLOCATOR_H
|
|
#define LLVM_SUPPORT_ALLOCATOR_H
|
|
|
|
#include "llvm/Support/AlignOf.h"
|
|
#include <cstdlib>
|
|
|
|
namespace llvm {
|
|
|
|
class MallocAllocator {
|
|
public:
|
|
MallocAllocator() {}
|
|
~MallocAllocator() {}
|
|
|
|
void Reset() {}
|
|
|
|
void *Allocate(size_t Size, size_t /*Alignment*/) { return malloc(Size); }
|
|
|
|
template <typename T>
|
|
T *Allocate() { return static_cast<T*>(malloc(sizeof(T))); }
|
|
|
|
void Deallocate(void *Ptr) { free(Ptr); }
|
|
|
|
void PrintStats() const {}
|
|
};
|
|
|
|
/// BumpPtrAllocator - This allocator is useful for containers that need very
|
|
/// simple memory allocation strategies. In particular, this just keeps
|
|
/// allocating memory, and never deletes it until the entire block is dead. This
|
|
/// makes allocation speedy, but must only be used when the trade-off is ok.
|
|
class BumpPtrAllocator {
|
|
BumpPtrAllocator(const BumpPtrAllocator &); // do not implement
|
|
void operator=(const BumpPtrAllocator &); // do not implement
|
|
|
|
void *TheMemory;
|
|
public:
|
|
BumpPtrAllocator();
|
|
~BumpPtrAllocator();
|
|
|
|
void Reset();
|
|
|
|
void *Allocate(size_t Size, size_t Alignment);
|
|
|
|
template <typename T>
|
|
T *Allocate() {
|
|
return static_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment));
|
|
}
|
|
|
|
template <typename T>
|
|
T *Allocate(size_t Num) {
|
|
return static_cast<T*>(Allocate(Num * sizeof(T), AlignOf<T>::Alignment));
|
|
}
|
|
|
|
void Deallocate(void * /*Ptr*/) {}
|
|
|
|
void PrintStats() const;
|
|
};
|
|
|
|
} // end namespace llvm
|
|
|
|
#endif
|