Skip to content

Commit 9bff1da

Browse files
committed
[RegAlloc] Add scaffold for -regalloc=segmenttree (NFC)
Adds a minimal factory + regalloc registration for . Currently delegates to Greedy allocator. No functional change.
1 parent d4f7995 commit 9bff1da

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===- RegAllocSegmentTree.h - RA segtree scaffold --------------*- C++ -*-===//
2+
//
3+
// This file declares createRegAllocSegmentTree() factory (scaffold only).
4+
//
5+
//===----------------------------------------------------------------------===//
6+
7+
#ifndef LLVM_CODEGEN_REGALLOCSEGMENTTREE_H
8+
#define LLVM_CODEGEN_REGALLOCSEGMENTTREE_H
9+
10+
namespace llvm {
11+
class FunctionPass;
12+
13+
// Factory (for -regalloc=segtre). For now it delegates to Greedy (NFC).
14+
FunctionPass *createRegAllocSegmentTree();
15+
} // end namespace llvm
16+
17+
#endif

llvm/lib/CodeGen/CodeGen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
113113
initializeRABasicPass(Registry);
114114
initializeRAGreedyLegacyPass(Registry);
115115
initializeRegAllocFastPass(Registry);
116+
// initializeRegAllocSegmentTreePass(Registry); // Add this line
116117
initializeRegUsageInfoCollectorLegacyPass(Registry);
117118
initializeRegUsageInfoPropagationLegacyPass(Registry);
118119
initializeRegisterCoalescerLegacyPass(Registry);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===- RegAllocSegmentTree.cpp - RA segtree scaffold ----------------------===//
2+
//
3+
// Scaffold only: register -regalloc=segmenttree that delegates to Greedy (NFC).
4+
//
5+
//===----------------------------------------------------------------------===//
6+
7+
#include "llvm/CodeGen/RegAllocSegmentTree.h"
8+
#include "llvm/CodeGen/RegAllocRegistry.h"
9+
10+
using namespace llvm;
11+
12+
// 工廠:目前直接委派回 Greedy(零行為變更)
13+
FunctionPass *llvm::createRegAllocSegmentTree() {
14+
extern FunctionPass *createGreedyRegisterAllocator();
15+
return createGreedyRegisterAllocator();
16+
}
17+
18+
// 把選項掛進 -regalloc= 名單(名稱、描述、工廠)
19+
static RegisterRegAlloc
20+
RAReg("segmenttree", "Segment Tree Register Allocator (scaffold)",
21+
createRegAllocSegmentTree);

0 commit comments

Comments
 (0)